本文整理汇总了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);
}
}