本文整理匯總了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}