當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。