本文整理匯總了Java中android.widget.RelativeLayout.LayoutParams.setMargins方法的典型用法代碼示例。如果您正苦於以下問題:Java LayoutParams.setMargins方法的具體用法?Java LayoutParams.setMargins怎麽用?Java LayoutParams.setMargins使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.RelativeLayout.LayoutParams
的用法示例。
在下文中一共展示了LayoutParams.setMargins方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addTab
import android.widget.RelativeLayout.LayoutParams; //導入方法依賴的package包/類
protected void addTab(int index, CharSequence text, int iconResId) {
TabView tabView = new TabView(this, getContext(), text);
tabView.setIndex(index);
tabView.setFocusable(true);
tabView.setOnClickListener(this.mTabClickListener);
if (iconResId != 0) {
tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
}
int width = this.mMeanWidth == -1 ? getTabWidth(text) : this.mMeanWidth;
if (this.mMeanWidth != -1) {
tabView.setSize(this.mMeanWidth, UIsUtils.dipToPx(38.0f));
} else {
tabView.setSize(width, UIsUtils.dipToPx(38.0f));
}
RelativeLayout relativeLayout = new RelativeLayout(this.mContext);
relativeLayout.setGravity(17);
relativeLayout.setLayoutParams(new LayoutParams(-2, UIsUtils.dipToPx(38.0f)));
LayoutParams params = new LayoutParams(-2, UIsUtils.dipToPx(38.0f));
params.setMargins(TAB_MARGIN, 0, TAB_MARGIN, 0);
tabView.setLayoutParams(params);
relativeLayout.addView(tabView);
if (this.mIsHome) {
ThemeDataManager.getInstance(this.mContext).setContentTheme(tabView, ThemeDataManager.NAME_TOP_NAVIGATION_COLOR);
}
ImageView imageView = new ImageView(this.mContext);
LayoutParams imageViewParams = new LayoutParams(width, UIsUtils.dipToPx(2.0f));
imageViewParams.setMargins(TAB_MARGIN, UIsUtils.dipToPx(36.0f), TAB_MARGIN, 0);
imageView.setLayoutParams(imageViewParams);
relativeLayout.addView(imageView);
imageView.setBackgroundDrawable(getResources().getDrawable(2130838177));
if (this.mIsHome) {
ThemeDataManager.getInstance(this.mContext).setShapeSelectorViewTheme(imageView, ThemeDataManager.NAME_TOP_NAVIGATION_COLOR, 2, true);
}
this.mTabLayout.addView(relativeLayout);
}
示例2: addMirrorView
import android.widget.RelativeLayout.LayoutParams; //導入方法依賴的package包/類
private ImageView addMirrorView(ViewGroup parent, RecyclerView recyclerView, View view) {
view.destroyDrawingCache();
view.setDrawingCacheEnabled(true);
ImageView mirrorView = new ImageView(recyclerView.getContext());
Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
mirrorView.setImageBitmap(bitmap);
view.setDrawingCacheEnabled(false);
int[] locations = new int[2];
view.getLocationOnScreen(locations);
int[] parenLocations = new int[2];
recyclerView.getLocationOnScreen(parenLocations);
LayoutParams params = new LayoutParams(bitmap.getWidth(), bitmap.getHeight());
params.setMargins(locations[0], (locations[1] - parenLocations[1]) + UIsUtils.dipToPx(44.0f), 0, 0);
parent.addView(mirrorView, params);
return mirrorView;
}
示例3: getPageBody
import android.widget.RelativeLayout.LayoutParams; //導入方法依賴的package包/類
private LinearLayout getPageBody() {
this.llBody = new LinearLayout(getContext());
this.llBody.setId(2);
int resId = R.getBitmapRes(this.activity, "edittext_back");
if (resId > 0) {
this.llBody.setBackgroundResource(resId);
}
this.llBody.setOrientation(1);
LayoutParams lpBody = new LayoutParams(-2, -2);
lpBody.addRule(5, this.llTitle.getId());
lpBody.addRule(3, this.llTitle.getId());
lpBody.addRule(7, this.llTitle.getId());
if (!this.dialogMode) {
lpBody.addRule(12);
}
int dp_3 = R.dipToPx(getContext(), 3);
lpBody.setMargins(dp_3, dp_3, dp_3, dp_3);
this.llBody.setLayoutParams(lpBody);
this.llBody.addView(getMainBody());
this.llBody.addView(getSep());
this.llBody.addView(getPlatformList());
return this.llBody;
}
示例4: initView
import android.widget.RelativeLayout.LayoutParams; //導入方法依賴的package包/類
private void initView() {
if (!this.dialogMode) {
RelativeLayout mainRelLayout = (RelativeLayout) findViewByResName("mainRelLayout");
LayoutParams lp = (LayoutParams) mainRelLayout.getLayoutParams();
lp.setMargins(0, 0, 0, 0);
lp.height = -1;
mainRelLayout.setLayoutParams(lp);
}
initTitleView();
initBodyView();
initImageListView();
}