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


Java MarginLayoutParams.setMargins方法代码示例

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


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

示例1: updatePosition

import android.view.ViewGroup.MarginLayoutParams; //导入方法依赖的package包/类
private void updatePosition() {
    MarginLayoutParams lp = null;
    if (mContainerType == ContainerType.STATUSBAR) {
        lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                mHeightPx);
        ((FrameLayout.LayoutParams)lp).gravity = mPosition == Position.TOP ? 
            Gravity.TOP : Gravity.BOTTOM;
    } else if (mContainerType == ContainerType.KEYGUARD) {
        lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
                mHeightPx);
        if (mPosition == Position.TOP) {
            ((RelativeLayout.LayoutParams)lp).addRule(RelativeLayout.ALIGN_PARENT_TOP,
                    RelativeLayout.TRUE);
        } else {
            ((RelativeLayout.LayoutParams)lp).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,
                    RelativeLayout.TRUE);
        }
    }

    if (lp != null) {
        lp.setMargins(0, mPosition == Position.TOP ? mMarginPx : 0,
                    0, mPosition == Position.BOTTOM ? mMarginPx : 0);
        setLayoutParams(lp);
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:26,代码来源:BatteryBarView.java

示例2: 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

示例3: 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

示例4: updatePosition

import android.view.ViewGroup.MarginLayoutParams; //导入方法依赖的package包/类
private void updatePosition() {
    if (mMode == Mode.OFF) return;

    MarginLayoutParams lp = null;
    if (mContainerType == ContainerType.STATUSBAR) {
        lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                mHeightPx);
        ((FrameLayout.LayoutParams)lp).gravity = mMode == Mode.TOP ? 
                Gravity.TOP : Gravity.BOTTOM;
    } else if (mContainerType == ContainerType.KEYGUARD) {
        lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
                mHeightPx);
        if (mMode == Mode.TOP) {
            ((RelativeLayout.LayoutParams)lp).addRule(RelativeLayout.ALIGN_PARENT_TOP,
                    RelativeLayout.TRUE);
        } else {
            ((RelativeLayout.LayoutParams)lp).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,
                    RelativeLayout.TRUE);
        }
    }

    if (lp != null) {
        lp.setMargins(0, mMode == Mode.TOP ? mEdgeMarginPx : 0,
                      0, mMode == Mode.BOTTOM ? mEdgeMarginPx : 0);
        setLayoutParams(lp);
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:28,代码来源:ProgressBarView.java

示例5: 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, 0, 0);
    }
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:11,代码来源:ViewLayoutUtils.java


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