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


Java MarginLayoutParams类代码示例

本文整理汇总了Java中android.view.ViewGroup.MarginLayoutParams的典型用法代码示例。如果您正苦于以下问题:Java MarginLayoutParams类的具体用法?Java MarginLayoutParams怎么用?Java MarginLayoutParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: adjustViewPosition

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
void adjustViewPosition() {
    mParent.getWindowVisibleDisplayFrame(mCurrentVisibleRect);
    // Only update if the visible frame has changed, otherwise there will be a layout loop.
    if (!mCurrentVisibleRect.equals(mPreviousVisibleRect)) {
        mPreviousVisibleRect.set(mCurrentVisibleRect);

        int keyboardHeight = mParent.getHeight() - mCurrentVisibleRect.bottom
                + mCurrentVisibleRect.top;
        MarginLayoutParams lp = getLayoutParams();
        lp.bottomMargin = keyboardHeight;
        if (mIsTablet) {
            int margin = mParent.getResources()
                    .getDimensionPixelSize(R.dimen.snackbar_margin_tablet);
            ApiCompatibilityUtils.setMarginStart(lp, margin);
            lp.bottomMargin += margin;
            int width = mParent.getResources()
                    .getDimensionPixelSize(R.dimen.snackbar_width_tablet);
            lp.width = Math.min(width, mParent.getWidth() - 2 * margin);
        }
        mView.setLayoutParams(lp);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:23,代码来源:SnackbarView.java

示例2: findView

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
private void findView() {
    this.mOperationBarView = this.root.findViewById(2131362660);
    this.mFooterLayout = UIs.inflate(this.mActivity, R.layout.fragment_my_download_worldcup_bottom, null);
    this.mFootCloseBtn = (Button) this.mFooterLayout.findViewById(R.id.btn_close_worldcup);
    this.mNullScrollView = (ScrollView) this.root.findViewById(R.id.scrollview_tip);
    this.mNullTip = (LinearLayout) this.root.findViewById(R.id.linearlayout_tip_download);
    this.mTextOpenTip = (TextView) this.root.findViewById(R.id.textv_open_worldcup_tip);
    ((MarginLayoutParams) this.mTextOpenTip.getLayoutParams()).topMargin = UIs.zoomWidth(LiveType.PLAY_LIVE_OTHER);
    this.mTextOpenSubTip = (TextView) this.root.findViewById(R.id.textv_open_worldcup_tip_line2);
    ((MarginLayoutParams) this.mTextOpenSubTip.getLayoutParams()).topMargin = UIs.zoomWidth(9);
    this.mListView = (ListView) this.root.findViewById(2131361938);
    this.mStartAllBtn = (Button) this.mOperationBarView.findViewById(2131362659);
    this.mPauseAllBtn = (Button) this.mOperationBarView.findViewById(2131362658);
    this.mOpenWorldCupBtn = (Button) this.root.findViewById(R.id.btn_open_close);
    this.mStartAllBtn.setOnClickListener(this.onClick);
    this.mPauseAllBtn.setOnClickListener(this.onClick);
    this.mOpenWorldCupBtn.setOnClickListener(this.onClick);
    this.mFootCloseBtn.setOnClickListener(this.onClick);
    this.mDialog = new CustomLoadingDialog(this.mActivity);
    this.mDialog.setCanceledOnTouchOutside(false);
    this.rootWatchAlertLayout = (RelativeLayout) this.root.findViewById(R.id.road_watch_ball_alert_layout);
    ((TextView) this.rootWatchAlertLayout.findViewById(R.id.road_watch_ball_alert)).setText(LetvTools.getTextFromServer(DialogMsgConstantId.CONSTANT_70013, getActivity().getResources().getString(2131100080)));
    this.rootWatchAlertLayout.setOnClickListener(this.onClick);
    setText();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:MyRandomSeeFragment.java

示例3: setGridViewHeightBasedOnChildren

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
public static void setGridViewHeightBasedOnChildren(GridView listView,int col) {
	// 获取listview的adapter
	ListAdapter listAdapter = listView.getAdapter();
	if (listAdapter == null) {
		return;
	}
	// 固定列宽,有多少列
	int totalHeight = 0;
	// i每次加4,相当于listAdapter.getCount()小于等于4时 循环一次,计算一次item的高度,
	// listAdapter.getCount()小于等于8时计算两次高度相加
	for (int i = 0; i < listAdapter.getCount(); i += col) {
		// 获取listview的每一个item
		View listItem = listAdapter.getView(i, null, listView);
		listItem.measure(0, 0);
		// 获取item的高度和
		totalHeight += listItem.getMeasuredHeight();
		totalHeight += listView.getVerticalSpacing();
		if (i==listAdapter.getCount()-1) {
			totalHeight += listView.getVerticalSpacing();
		}
	}
	// 获取listview的布局参数
	LayoutParams params = listView.getLayoutParams();
	// 设置高度
	params.height = totalHeight;
	// 设置margin
	((MarginLayoutParams) params).setMargins(10, 10, 10, 10);
	// 设置参数
	listView.setLayoutParams(params);
}
 
开发者ID:Jay-Ping,项目名称:newIPlay,代码行数:31,代码来源:FixedViewUtil.java

示例4: placeViewAt

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
public static void placeViewAt(final View view, final int x, final int y, final int w,
        final int h) {
    final ViewGroup.LayoutParams lp = view.getLayoutParams();
    if (lp instanceof MarginLayoutParams) {
        final MarginLayoutParams marginLayoutParams = (MarginLayoutParams)lp;
        marginLayoutParams.width = w;
        marginLayoutParams.height = h;
        marginLayoutParams.setMargins(x, y, -50, 0);
    }
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:11,代码来源:ViewLayoutUtils.java

示例5: setMarginEnd

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
/**
 * @see android.view.ViewGroup.MarginLayoutParams#setMarginEnd(int)
 */
public static void setMarginEnd(MarginLayoutParams layoutParams, int end) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        layoutParams.setMarginEnd(end);
    } else {
        layoutParams.rightMargin = end;
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:11,代码来源:ApiCompatibilityUtils.java

示例6: getMarginStart

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
/**
 * @see android.view.ViewGroup.MarginLayoutParams#getMarginStart()
 */
public static int getMarginStart(MarginLayoutParams layoutParams) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return layoutParams.getMarginStart();
    } else {
        return layoutParams.leftMargin;
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:11,代码来源:ApiCompatibilityUtils.java

示例7: getContainer

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
public View getContainer(String viewType, int containerType, boolean createParam) {
    IContainer container = null;

    ViewBase vb = mVM.getView(viewType);
    if (null == vb) {
        vb = mVM.getDefaultImage();
        vb.setViewType(viewType);
    }

    if (vb.isContainer()) {
        container = (IContainer) vb.getNativeView();
    } else {
        ContainerMrg cm = mContainerMrg.get(containerType);
        if (null != cm) {
            container = cm.getContainer(mAppContext);
        } else {
            Log.e(TAG, "getContainer type invalidate:" + containerType);
        }
    }

    if (null != container) {
        container.setVirtualView(vb);
        if (createParam) {
            Layout.Params p = vb.getComLayoutParams();
            MarginLayoutParams marginLayoutParams = new MarginLayoutParams(p.mLayoutWidth, p.mLayoutHeight);
            marginLayoutParams.leftMargin = p.mLayoutMarginLeft;
            marginLayoutParams.topMargin = p.mLayoutMarginTop;
            marginLayoutParams.rightMargin = p.mLayoutMarginRight;
            marginLayoutParams.bottomMargin = p.mLayoutMarginBottom;
            ((View)container).setLayoutParams(marginLayoutParams);
        }

        container.attachViews();
    }
    return (View)container;
}
 
开发者ID:alibaba,项目名称:Virtualview-Android,代码行数:37,代码来源:ContainerService.java

示例8: showTabMenu

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
/**
 * Displays the tab menu below the anchor tab.
 * @param anchorTab The tab the menu will be anchored to
 */
private void showTabMenu(StripLayoutTab anchorTab) {
    // 1. Bring the anchor tab to the foreground.
    int tabIndex = TabModelUtils.getTabIndexById(mModel, anchorTab.getId());
    TabModelUtils.setIndex(mModel, tabIndex);

    // 2. Anchor the popupMenu to the view associated with the tab
    View tabView = TabModelUtils.getCurrentTab(mModel).getView();
    mTabMenu.setAnchorView(tabView);

    // 3. Set the vertical offset to align the tab menu with bottom of the tab strip
    int verticalOffset =
            -(tabView.getHeight()
                    - (int) mContext.getResources().getDimension(R.dimen.tab_strip_height))
            - ((MarginLayoutParams) tabView.getLayoutParams()).topMargin;
    mTabMenu.setVerticalOffset(verticalOffset);

    // 4. Set the horizontal offset to align the tab menu with the right side of the tab
    int horizontalOffset = Math.round((anchorTab.getDrawX() + anchorTab.getWidth())
                                   * mContext.getResources().getDisplayMetrics().density)
            - mTabMenu.getWidth()
            - ((MarginLayoutParams) tabView.getLayoutParams()).leftMargin;
    // Cap the horizontal offset so that the tab menu doesn't get drawn off screen.
    horizontalOffset = Math.max(horizontalOffset, 0);
    mTabMenu.setHorizontalOffset(horizontalOffset);

    mTabMenu.show();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:32,代码来源:StripLayoutHelper.java

示例9: setAbsListViewHeight

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
public static void setAbsListViewHeight(AbsListView absListView, int lineNumber, int verticalSpace) {
    int totalHeight = getAbsListViewHeight(absListView, lineNumber, verticalSpace);
    ViewGroup.LayoutParams params = absListView.getLayoutParams();
    params.height = totalHeight;
    ((MarginLayoutParams) params).setMargins(0, 0, 0, 0);
    absListView.setLayoutParams(params);
}
 
开发者ID:yangchong211,项目名称:YCWeather,代码行数:8,代码来源:ViewUtil.java

示例10: updateMargins

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
private void updateMargins() {
    MarginLayoutParams layoutParams = (MarginLayoutParams) mView.getLayoutParams();
    if (mCurrentDisplayStyle == UiConfig.DISPLAY_STYLE_WIDE) {
        layoutParams.setMargins(mWideMarginSizePixels, layoutParams.topMargin,
                mWideMarginSizePixels, layoutParams.bottomMargin);
    } else {
        layoutParams.setMargins(mDefaultMarginSizePixels, layoutParams.topMargin,
                mDefaultMarginSizePixels, layoutParams.bottomMargin);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:11,代码来源:MarginResizer.java

示例11: generateLayoutParams

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
public LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams lp) {
    if (lp instanceof LayoutParams) {
        return new LayoutParams((LayoutParams) lp);
    }
    if (lp instanceof MarginLayoutParams) {
        return new LayoutParams((MarginLayoutParams) lp);
    }
    return new LayoutParams(lp);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:10,代码来源:RecyclerView.java

示例12: newLayoutParam

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
public static MarginLayoutParams newLayoutParam(final ViewGroup placer, final int width,
        final int height) {
    if (placer instanceof FrameLayout) {
        return new FrameLayout.LayoutParams(width, height);
    } else if (placer instanceof RelativeLayout) {
        return new RelativeLayout.LayoutParams(width, height);
    } else if (placer == null) {
        throw new NullPointerException("placer is null");
    } else {
        throw new IllegalArgumentException("placer is neither FrameLayout nor RelativeLayout: "
                + placer.getClass().getName());
    }
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:14,代码来源:ViewLayoutUtils.java

示例13: updateTextAndIcon

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
private void updateTextAndIcon(@Nullable TextView textView, @Nullable ImageView iconView) {
    Drawable icon;
    CharSequence text;
    CharSequence contentDesc;
    boolean hasText;
    if (this.mTab != null) {
        icon = this.mTab.getIcon();
    } else {
        icon = null;
    }
    if (this.mTab != null) {
        text = this.mTab.getText();
    } else {
        text = null;
    }
    if (this.mTab != null) {
        contentDesc = this.mTab.getContentDescription();
    } else {
        contentDesc = null;
    }
    if (iconView != null) {
        if (icon != null) {
            iconView.setImageDrawable(icon);
            iconView.setVisibility(0);
            setVisibility(0);
        } else {
            iconView.setVisibility(8);
            iconView.setImageDrawable(null);
        }
        iconView.setContentDescription(contentDesc);
    }
    if (TextUtils.isEmpty(text)) {
        hasText = false;
    } else {
        hasText = true;
    }
    if (textView != null) {
        if (hasText) {
            textView.setText(text);
            textView.setVisibility(0);
            setVisibility(0);
        } else {
            textView.setVisibility(8);
            textView.setText(null);
        }
        textView.setContentDescription(contentDesc);
    }
    if (iconView != null) {
        MarginLayoutParams lp = (MarginLayoutParams) iconView.getLayoutParams();
        int bottomMargin = 0;
        if (hasText && iconView.getVisibility() == 0) {
            bottomMargin = TabLayout.this.dpToPx(8);
        }
        if (bottomMargin != lp.bottomMargin) {
            lp.bottomMargin = bottomMargin;
            iconView.requestLayout();
        }
    }
    if (hasText || TextUtils.isEmpty(contentDesc)) {
        setOnLongClickListener(null);
        setLongClickable(false);
        return;
    }
    setOnLongClickListener(this);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:66,代码来源:TabLayout.java

示例14: applyMarginInsets

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
public static void applyMarginInsets(MarginLayoutParams lp, Object insets, int gravity) {
    WindowInsets wi = (WindowInsets) insets;
    if (gravity == 3) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (gravity == 5) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:DrawerLayoutCompatApi21.java

示例15: getLayoutDirection

import android.view.ViewGroup.MarginLayoutParams; //导入依赖的package包/类
public static int getLayoutDirection(MarginLayoutParams lp) {
    int result = IMPL.getLayoutDirection(lp);
    if (result == 0 || result == 1) {
        return result;
    }
    return 0;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:8,代码来源:MarginLayoutParamsCompat.java


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