当前位置: 首页>>代码示例>>Java>>正文


Java LayoutParams.setMargins方法代码示例

本文整理汇总了Java中android.widget.FrameLayout.LayoutParams.setMargins方法的典型用法代码示例。如果您正苦于以下问题:Java LayoutParams.setMargins方法的具体用法?Java LayoutParams.setMargins怎么用?Java LayoutParams.setMargins使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.FrameLayout.LayoutParams的用法示例。


在下文中一共展示了LayoutParams.setMargins方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateView

import android.widget.FrameLayout.LayoutParams; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

	LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

	FrameLayout fl = new FrameLayout(getActivity());
	fl.setLayoutParams(params);

	final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources()
			.getDisplayMetrics());

	TextView v = new TextView(getActivity());
	params.setMargins(margin, margin, margin, margin);
	v.setLayoutParams(params);
	v.setLayoutParams(params);
	v.setGravity(Gravity.CENTER);
	v.setBackgroundResource(R.drawable.background_card);
	v.setText("CARD " + (position + 1));

	fl.addView(v);
	return fl;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:SuperAwesomeCardFragment.java

示例2: BasicNativePage

import android.widget.FrameLayout.LayoutParams; //导入方法依赖的package包/类
public BasicNativePage(Activity activity, Tab tab) {
    initialize(activity, tab);
    mActivity = activity;
    mTab = tab;
    mBackgroundColor = ApiCompatibilityUtils.getColor(activity.getResources(),
            R.color.default_primary_color);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);

    Resources res = mActivity.getResources();

    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    layoutParams.setMargins(0,
            res.getDimensionPixelSize(R.dimen.tab_strip_height)
            + res.getDimensionPixelSize(R.dimen.toolbar_height_no_shadow),
            0, 0);
    getView().setLayoutParams(layoutParams);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:BasicNativePage.java

示例3: addContentView

import android.widget.FrameLayout.LayoutParams; //导入方法依赖的package包/类
/**
 * Inflates the view, which is associated with a tab, and adds it to the view hierarchy.
 *
 * @param tabItem
 *         The tab item, which corresponds to the tab, whose associated view should be inflated,
 *         as an instance of the class {@link TabItem}. The tab item may not be null
 */
private void addContentView(@NonNull final TabItem tabItem) {
    PhoneTabViewHolder viewHolder = (PhoneTabViewHolder) tabItem.getViewHolder();
    View view = viewHolder.content;
    Tab tab = tabItem.getTab();

    if (view == null) {
        ViewGroup parent = viewHolder.contentContainer;
        Pair<View, ?> pair = tabViewRecycler.inflate(tab, parent);
        view = pair.first;
        LayoutParams layoutParams =
                new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        Rect padding = getPadding();
        layoutParams.setMargins(padding.left, padding.top, padding.right, padding.bottom);
        parent.addView(view, 0, layoutParams);
        viewHolder.content = view;
    } else {
        tabViewRecycler.getAdapter().onShowView(getModel().getContext(), view, tab, false);
    }

    viewHolder.previewImageView.setVisibility(View.GONE);
    viewHolder.previewImageView.setImageBitmap(null);
    viewHolder.borderView.setVisibility(View.GONE);
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:31,代码来源:PhoneTabRecyclerAdapter.java

示例4: addChildView

import android.widget.FrameLayout.LayoutParams; //导入方法依赖的package包/类
/**
 * Inflates the child view of a tab and adds it to the view hierarchy.
 *
 * @param tabItem
 *         The tab item, which corresponds to the tab, whose child view should be inflated, as
 *         an instance of the class {@link TabItem}. The tab item may not be null
 */
private void addChildView(@NonNull final TabItem tabItem) {
    PhoneTabViewHolder viewHolder = tabItem.getViewHolder();
    View view = viewHolder.child;
    Tab tab = tabItem.getTab();

    if (view == null) {
        ViewGroup parent = viewHolder.childContainer;
        Pair<View, ?> pair = childViewRecycler.inflate(tab, parent);
        view = pair.first;
        LayoutParams layoutParams =
                new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        layoutParams.setMargins(model.getPaddingLeft(), model.getPaddingTop(),
                model.getPaddingRight(), model.getPaddingBottom());
        parent.addView(view, 0, layoutParams);
        viewHolder.child = view;
    } else {
        childViewRecycler.getAdapter().onShowView(model.getContext(), view, tab, false);
    }

    viewHolder.previewImageView.setVisibility(View.GONE);
    viewHolder.previewImageView.setImageBitmap(null);
    viewHolder.borderView.setVisibility(View.GONE);
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:31,代码来源:PhoneRecyclerAdapter.java

示例5: adaptPadding

import android.widget.FrameLayout.LayoutParams; //导入方法依赖的package包/类
/**
 * Adapts the padding of a tab.
 *
 * @param viewHolder
 *         The view holder, which stores references to the tab's views, as an instance of the
 *         class {@link PhoneTabViewHolder}. The view holder may not be null
 */
private void adaptPadding(@NonNull final PhoneTabViewHolder viewHolder) {
    Rect padding = getPadding();

    if (viewHolder.content != null) {
        LayoutParams contentLayoutParams = (LayoutParams) viewHolder.content.getLayoutParams();
        contentLayoutParams
                .setMargins(padding.left, padding.top, padding.right, padding.bottom);
    }

    LayoutParams previewLayoutParams =
            (LayoutParams) viewHolder.previewImageView.getLayoutParams();
    previewLayoutParams.setMargins(padding.left, padding.top, padding.right, padding.bottom);
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:21,代码来源:PhoneTabRecyclerAdapter.java

示例6: adaptPadding

import android.widget.FrameLayout.LayoutParams; //导入方法依赖的package包/类
/**
 * Adapts the padding of a tab.
 *
 * @param viewHolder
 *         The view holder, which stores references to the tab's views, as an instance of the
 *         class {@link PhoneTabViewHolder}. The view holder may not be null
 */
private void adaptPadding(@NonNull final PhoneTabViewHolder viewHolder) {
    if (viewHolder.child != null) {
        LayoutParams childLayoutParams = (LayoutParams) viewHolder.child.getLayoutParams();
        childLayoutParams.setMargins(model.getPaddingLeft(), model.getPaddingTop(),
                model.getPaddingRight(), model.getPaddingBottom());
    }

    LayoutParams previewLayoutParams =
            (LayoutParams) viewHolder.previewImageView.getLayoutParams();
    previewLayoutParams
            .setMargins(model.getPaddingLeft(), model.getPaddingTop(), model.getPaddingRight(),
                    model.getPaddingBottom());
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:21,代码来源:PhoneRecyclerAdapter.java


注:本文中的android.widget.FrameLayout.LayoutParams.setMargins方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。