本文整理汇总了Java中android.widget.LinearLayout.LayoutParams.setMargins方法的典型用法代码示例。如果您正苦于以下问题:Java LayoutParams.setMargins方法的具体用法?Java LayoutParams.setMargins怎么用?Java LayoutParams.setMargins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.LinearLayout.LayoutParams
的用法示例。
在下文中一共展示了LayoutParams.setMargins方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processLogic
import android.widget.LinearLayout.LayoutParams; //导入方法依赖的package包/类
protected void processLogic() {
this.mIndicatorIvList = new ArrayList();
this.mGridViewList = new ArrayList();
int emotionPageCount = ((MQEmotionUtil.sEmotionKeyArr.length - 1) / 27) + 1;
LayoutParams indicatorIvLp = new LayoutParams(-2, -2);
int margin = MQUtils.dip2px(getContext(), 5.0f);
indicatorIvLp.setMargins(margin, margin, margin, margin);
for (int i = 0; i < emotionPageCount; i++) {
ImageView indicatorIv = new ImageView(getContext());
indicatorIv.setLayoutParams(indicatorIvLp);
indicatorIv.setImageResource(R.drawable.mq_selector_emotion_indicator);
indicatorIv.setEnabled(false);
this.mIndicatorIvList.add(indicatorIv);
this.mIndicatorLl.addView(indicatorIv);
this.mGridViewList.add(getGridView(i));
}
((ImageView) this.mIndicatorIvList.get(0)).setEnabled(true);
this.mContentVp.setAdapter(new EmotionPagerAdapter());
}
示例2: getAccessoryView
import android.widget.LinearLayout.LayoutParams; //导入方法依赖的package包/类
private static ImageView getAccessoryView(ATableViewCell cell, ATableViewCellAccessoryType accessoryType) {
LinearLayout containerView = (LinearLayout) cell.findViewById(R.id.containerView);
// check if accessoryView already exists for current cell before creating a new instance.
ImageView accessoryView = (ImageView) containerView.findViewById(R.id.accessoryView);
if (accessoryView == null) {
Resources res = cell.getResources();
// get marginRight for accessoryView, DisclosureButton has a different one.
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
int marginRight = (int) res.getDimension(R.dimen.atv_cell_content_margin);
if (accessoryType == ATableViewCellAccessoryType.DisclosureButton) {
marginRight = (int) res.getDimension(R.dimen.atv_cell_disclosure_button_margin_right);
}
params.setMargins(0, 0, marginRight, 0);
// setup.
accessoryView = new ATableViewCellAccessoryView(cell.getContext());
accessoryView.setId(R.id.accessoryView);
accessoryView.setLayoutParams(params);
containerView.addView(accessoryView);
}
return accessoryView;
}
示例3: setLabels
import android.widget.LinearLayout.LayoutParams; //导入方法依赖的package包/类
private void setLabels(TeamIssue issue) {
if (issue.getLabels() == null || issue.getLabels().isEmpty()) {
mLLlabels.setVisibility(View.GONE);
} else {
for (TeamIssue.Label label : issue.getLabels()) {
TextView text = (TextView) LayoutInflater.from(getActivity())
.inflate(R.layout.team_issue_lable, null, false);
text.setText(label.getName());
String colorStr = label.getColor();
if (colorStr.equalsIgnoreCase("#ffffff")) {
colorStr = "#000000";
}
int color = Color.parseColor(colorStr);
LayoutParams params = new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.setMargins(4, 0, 4, 0);
GradientDrawable d = (GradientDrawable) text.getBackground();
d.setStroke(1, color);
text.setTextColor(color);
mLLlabels.addView(text, params);
}
}
}
示例4: getMainBody
import android.widget.LinearLayout.LayoutParams; //导入方法依赖的package包/类
private LinearLayout getMainBody() {
LinearLayout llMainBody = new LinearLayout(getContext());
llMainBody.setOrientation(LinearLayout.VERTICAL);
LayoutParams lpMain = new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lpMain.weight = 1;
int dp_4 = dipToPx(getContext(), 4);
lpMain.setMargins(dp_4, dp_4, dp_4, dp_4);
llMainBody.setLayoutParams(lpMain);
LinearLayout llContent = new LinearLayout(getContext());
LayoutParams lpContent = new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lpContent.weight = 1;
llMainBody.addView(llContent, lpContent);
// share content editor
etContent = new EditText(getContext());
etContent.setGravity(Gravity.LEFT | Gravity.TOP);
etContent.setBackgroundDrawable(null);
etContent.setText(String.valueOf(shareParamMap.get("text")));
etContent.addTextChangedListener(this);
LayoutParams lpEt = new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lpEt.weight = 1;
etContent.setLayoutParams(lpEt);
llContent.addView(etContent);
llContent.addView(getThumbView());
llMainBody.addView(getBodyBottom());
return llMainBody;
}
示例5: getPlatformList
import android.widget.LinearLayout.LayoutParams; //导入方法依赖的package包/类
private LinearLayout getPlatformList() {
LinearLayout llToolBar = new LinearLayout(getContext());
LayoutParams lpTb = new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
llToolBar.setLayoutParams(lpTb);
TextView tvShareTo = new TextView(getContext());
int resId = getStringRes(activity, "share_to");
if (resId > 0) {
tvShareTo.setText(resId);
}
tvShareTo.setTextColor(0xffcfcfcf);
tvShareTo.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
int dp_9 = dipToPx(getContext(), 9);
LayoutParams lpShareTo = new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lpShareTo.gravity = Gravity.CENTER_VERTICAL;
lpShareTo.setMargins(dp_9, 0, 0, 0);
tvShareTo.setLayoutParams(lpShareTo);
llToolBar.addView(tvShareTo);
HorizontalScrollView sv = new HorizontalScrollView(getContext());
sv.setHorizontalScrollBarEnabled(false);
sv.setHorizontalFadingEdgeEnabled(false);
LayoutParams lpSv = new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lpSv.setMargins(dp_9, dp_9, dp_9, dp_9);
sv.setLayoutParams(lpSv);
llToolBar.addView(sv);
llPlat = new LinearLayout(getContext());
llPlat.setLayoutParams(new HorizontalScrollView.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
sv.addView(llPlat);
return llToolBar;
}
示例6: getView
import android.widget.LinearLayout.LayoutParams; //导入方法依赖的package包/类
public View getView(int position, View convertView, ViewGroup parent) {
FollowListItem item;
boolean simpleMode = "FacebookMessenger".equals(this.platform.getName());
if (convertView == null) {
View llItem = new LinearLayout(parent.getContext());
item = new FollowListItem();
llItem.setTag(item);
convertView = llItem;
int dp_52 = R.dipToPx(getContext(), 52);
int dp_10 = R.dipToPx(parent.getContext(), 10);
int dp_5 = R.dipToPx(parent.getContext(), 5);
if (!simpleMode) {
item.aivIcon = new AsyncImageView(getContext());
LayoutParams lpIcon = new LayoutParams(dp_52, dp_52);
lpIcon.gravity = 16;
lpIcon.setMargins(dp_10, dp_5, dp_10, dp_5);
item.aivIcon.setLayoutParams(lpIcon);
llItem.addView(item.aivIcon);
}
LinearLayout llText = new LinearLayout(parent.getContext());
llText.setPadding(0, dp_10, dp_10, dp_10);
llText.setOrientation(1);
LayoutParams lpText = new LayoutParams(-2, -2);
lpText.gravity = 16;
lpText.weight = 1.0f;
llText.setLayoutParams(lpText);
llItem.addView(llText);
item.tvName = new TextView(parent.getContext());
item.tvName.setTextColor(-16777216);
item.tvName.setTextSize(1, 18.0f);
item.tvName.setSingleLine();
if (simpleMode) {
item.tvName.setPadding(dp_10, 0, 0, 0);
}
llText.addView(item.tvName);
if (!simpleMode) {
item.tvSign = new TextView(parent.getContext());
item.tvSign.setTextColor(2130706432);
item.tvSign.setTextSize(1, 14.0f);
item.tvSign.setSingleLine();
llText.addView(item.tvSign);
}
item.ivCheck = new ImageView(parent.getContext());
item.ivCheck.setPadding(0, 0, dp_10, 0);
LayoutParams lpCheck = new LayoutParams(-2, -2);
lpCheck.gravity = 16;
item.ivCheck.setLayoutParams(lpCheck);
llItem.addView(item.ivCheck);
} else {
item = (FollowListItem) convertView.getTag();
}
Following following = getItem(position);
item.tvName.setText(following.screenName);
if (!simpleMode) {
item.tvSign.setText(following.description);
}
item.ivCheck.setImageBitmap(following.checked ? this.bmChd : this.bmUnch);
if (!simpleMode) {
if (isFling()) {
Bitmap bm = BitmapProcessor.getBitmapFromCache(following.icon);
if (bm == null || bm.isRecycled()) {
item.aivIcon.execute(null, 0);
} else {
item.aivIcon.setImageBitmap(bm);
}
} else {
item.aivIcon.execute(following.icon, 0);
}
}
if (position == getCount() - 1) {
next();
}
return convertView;
}
示例7: getView
import android.widget.LinearLayout.LayoutParams; //导入方法依赖的package包/类
private LinearLayout getView(int position, OnClickListener ocL, Context context) {
Bitmap logo;
String label;
OnClickListener listener;
if (this.beans[position] instanceof Platform) {
logo = getIcon((Platform) this.beans[position]);
label = getName((Platform) this.beans[position]);
listener = ocL;
} else {
logo = ((CustomerLogo) this.beans[position]).enableLogo;
label = ((CustomerLogo) this.beans[position]).label;
listener = ocL;
}
LinearLayout ll = new LinearLayout(context);
ll.setOrientation(1);
ImageView iv = new ImageView(context);
int dp_5 = R.dipToPx(context, 5);
iv.setPadding(dp_5, dp_5, dp_5, dp_5);
iv.setScaleType(ScaleType.CENTER_INSIDE);
LayoutParams lpIv = new LayoutParams(-2, -2);
lpIv.setMargins(dp_5, dp_5, dp_5, dp_5);
lpIv.gravity = 1;
iv.setLayoutParams(lpIv);
iv.setImageBitmap(logo);
ll.addView(iv);
TextView tv = new TextView(context);
tv.setTextColor(AbstractWheelTextAdapter.DEFAULT_TEXT_COLOR);
tv.setTextSize(1, 14.0f);
tv.setSingleLine();
tv.setIncludeFontPadding(false);
LayoutParams lpTv = new LayoutParams(-2, -2);
lpTv.gravity = 1;
lpTv.weight = 1.0f;
lpTv.setMargins(dp_5, 0, dp_5, dp_5);
tv.setLayoutParams(lpTv);
tv.setText(label);
ll.addView(tv);
ll.setOnClickListener(listener);
return ll;
}
示例8: disableButton
import android.widget.LinearLayout.LayoutParams; //导入方法依赖的package包/类
public void disableButton(int id)
{
View button = findViewById(id);
final View other = findViewById(id == R.id.dialog_button_ok ? R.id.dialog_button_cancel : R.id.dialog_button_ok);
if (button != null && other != null)
{
button.setVisibility(View.GONE);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.setMargins(0, 0, 0, getContext().getResources().getDimensionPixelSize(R.dimen.dialog_buttons_margin));
other.setLayoutParams(lp);
findViewById(R.id.dialog_button_devider).setVisibility(View.GONE);
}
}
示例9: afterPlatformListGot
import android.widget.LinearLayout.LayoutParams; //导入方法依赖的package包/类
/** display platform list */
public void afterPlatformListGot() {
int size = platformList == null ? 0 : platformList.length;
views = new View[size];
final int dp_24 = dipToPx(getContext(), 24);
LayoutParams lpItem = new LayoutParams(dp_24, dp_24);
final int dp_9 = dipToPx(getContext(), 9);
lpItem.setMargins(0, 0, dp_9, 0);
FrameLayout.LayoutParams lpMask = new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
lpMask.gravity = Gravity.LEFT | Gravity.TOP;
int selection = 0;
for (int i = 0; i < size; i++) {
FrameLayout fl = new FrameLayout(getContext());
fl.setLayoutParams(lpItem);
if (i >= size - 1) {
fl.setLayoutParams(new LayoutParams(dp_24, dp_24));
}
llPlat.addView(fl);
fl.setOnClickListener(this);
ImageView iv = new ImageView(getContext());
iv.setScaleType(ScaleType.CENTER_INSIDE);
iv.setImageBitmap(getPlatLogo(platformList[i]));
iv.setLayoutParams(new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
fl.addView(iv);
views[i] = new View(getContext());
views[i].setBackgroundColor(0xcfffffff);
views[i].setOnClickListener(this);
String platformName = platformList[i].getName();
for(Platform plat : platforms) {
if(platformName.equals(plat.getName())) {
views[i].setVisibility(View.INVISIBLE);
selection = i;
}
}
views[i].setLayoutParams(lpMask);
fl.addView(views[i]);
}
final int postSel = selection;
UIHandler.sendEmptyMessageDelayed(0, 333, new Callback() {
public boolean handleMessage(Message msg) {
HorizontalScrollView hsv = (HorizontalScrollView)llPlat.getParent();
hsv.scrollTo(postSel * (dp_24 + dp_9), 0);
return false;
}
});
}