本文整理汇总了Java中android.widget.LinearLayout.LayoutParams类的典型用法代码示例。如果您正苦于以下问题:Java LayoutParams类的具体用法?Java LayoutParams怎么用?Java LayoutParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LayoutParams类属于android.widget.LinearLayout包,在下文中一共展示了LayoutParams类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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());
}
示例3: createTabView
import android.widget.LinearLayout.LayoutParams; //导入依赖的package包/类
@Override
public View createTabView(LayoutInflater inflater, ViewGroup tabsView) {
// we need to inflate the view based on the layout id specified when
// this instance was created.
View indicator = inflater.inflate(
_tabLayoutId,
tabsView,
false);
// set up the title of the tab. this will populate the text with the
// string defined by the resource passed in when this instance was
// created. the text will also be centered within the title control.
TextView titleView = (TextView)indicator.findViewById(_tabTitleViewId);
titleView.setText(_tabTitleResourceId);
titleView.setGravity(Gravity.CENTER);
// ensure the control we're inflating is layed out properly. this will
// cause our tab titles to be placed evenly weighted across the top.
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
layoutParams.weight = 1;
indicator.setLayoutParams(layoutParams);
return indicator;
}
示例4: onCreate
import android.widget.LinearLayout.LayoutParams; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result);
Bundle extras = getIntent().getExtras();
mResultImage = (ImageView) findViewById(R.id.result_image);
mResultText = (TextView) findViewById(R.id.result_text);
if (null != extras) {
int width = extras.getInt("width");
int height = extras.getInt("height");
LayoutParams lps = new LayoutParams(width, height);
lps.topMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics());
lps.leftMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics());
lps.rightMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics());
mResultImage.setLayoutParams(lps);
String result = extras.getString("result");
mResultText.setText(result);
Bitmap barcode = null;
byte[] compressedBitmap = extras.getByteArray(DecodeThread.BARCODE_BITMAP);
if (compressedBitmap != null) {
barcode = BitmapFactory.decodeByteArray(compressedBitmap, 0, compressedBitmap.length, null);
// Mutable copy:
barcode = barcode.copy(Bitmap.Config.RGB_565, true);
}
mResultImage.setImageBitmap(barcode);
}
}
示例5: getPageView
import android.widget.LinearLayout.LayoutParams; //导入依赖的package包/类
private RelativeLayout getPageView() {
rlPage = new RelativeLayout(getContext());
rlPage.setBackgroundDrawable(background);
if (dialogMode) {
RelativeLayout rlDialog = new RelativeLayout(getContext());
rlDialog.setBackgroundColor(0xc0323232);
int dp_8 = dipToPx(getContext(), 8);
int width = getScreenWidth(getContext()) - dp_8 * 2;
RelativeLayout.LayoutParams lpDialog = new RelativeLayout.LayoutParams(
width, LayoutParams.WRAP_CONTENT);
lpDialog.topMargin = dp_8;
lpDialog.bottomMargin = dp_8;
lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
rlDialog.setLayoutParams(lpDialog);
rlPage.addView(rlDialog);
rlDialog.addView(getPageTitle());
rlDialog.addView(getPageBody());
rlDialog.addView(getImagePin());
} else {
rlPage.addView(getPageTitle());
rlPage.addView(getPageBody());
rlPage.addView(getImagePin());
}
return rlPage;
}
示例6: init
import android.widget.LinearLayout.LayoutParams; //导入依赖的package包/类
private void init(Context context) {
calPageSize();
setOrientation(1);
this.pager = new ViewPagerClassic(context);
disableOverScrollMode(this.pager);
this.pager.setLayoutParams(new LayoutParams(-1, -2));
addView(this.pager);
new Thread() {
public void run() {
try {
PlatformGridView.this.platformList = ShareSDK.getPlatformList();
if (PlatformGridView.this.platformList == null) {
PlatformGridView.this.platformList = new Platform[0];
}
UIHandler.sendEmptyMessage(1, PlatformGridView.this);
} catch (Throwable t) {
t.printStackTrace();
}
}
}.start();
}
示例7: builder
import android.widget.LinearLayout.LayoutParams; //导入依赖的package包/类
public HotsDialog builder() {
view = LayoutInflater.from(context).inflate(R.layout.common_hotsdialog, null);
lLayout_bg = (RelativeLayout) view.findViewById(R.id.layout_bg);
txt_title = (TextView) view.findViewById(R.id.txt_title);
txt_title.setVisibility(View.VISIBLE);
txt_msg = (TextView) view.findViewById(R.id.txt_msg);
txt_msg.setVisibility(View.VISIBLE);
txt_point = (TextView) view.findViewById(R.id.txt_point);
btn_neg = (Button) view.findViewById(R.id.btn_neg);
btn_neg.setVisibility(View.VISIBLE);
btn_mid = (Button) view.findViewById(R.id.btn_mid);
btn_mid.setVisibility(View.VISIBLE);
dialog = new Dialog(context, R.style.AlertDialogStyle);
dialog.setContentView(view);
lLayout_bg.setLayoutParams(new FrameLayout.LayoutParams((int) (
display.getWidth() * 0.85), LayoutParams.WRAP_CONTENT));
return this;
}
示例8: setNavigations
import android.widget.LinearLayout.LayoutParams; //导入依赖的package包/类
public void setNavigations() {
removeAllViews();
int height = UIsUtils.dipToPx(49.0f);
NavigationType[] types = NavigationType.values();
int len = types.length;
for (int i = 0; i < len; i++) {
LayoutParams params = new LayoutParams(height, height);
if (i == 0) {
params.leftMargin = UIsUtils.dipToPx(14.0f);
} else {
params.leftMargin = ((UIsUtils.getScreenWidth() - (UIsUtils.dipToPx(14.0f) * 2)) - (len * height)) / (len - 1);
}
BottomNavigationItemView itemView = new BottomNavigationItemView(this, this.mContext);
itemView.setData(types[i]);
addView(itemView, params);
}
setSelectedType(NavigationType.HOME);
}
示例9: afterTextChanged
import android.widget.LinearLayout.LayoutParams; //导入依赖的package包/类
public void afterTextChanged(Editable s) {
int length = calculateLength(s.toString());
this.mFeedBackEditText.removeTextChangedListener(this);
if (length > LeMessageIds.MSG_FLOAT_BALL_REQUEST_DATA) {
this.mNumberTextView.setTextColor(getResources().getColor(2131493199));
} else {
this.mNumberTextView.setTextColor(getResources().getColor(2131493160));
}
this.mNumberTextView.setText(String.valueOf(length / 2));
LayoutParams params = (LayoutParams) this.mFeedBackEditText.getLayoutParams();
if (this.mHeight == -1) {
this.mHeight = params.height;
}
if (this.mFeedBackEditText.getLineCount() > 5) {
params.height = -2;
this.mFeedBackEditText.setLayoutParams(params);
} else {
params.height = this.mHeight;
this.mFeedBackEditText.setLayoutParams(params);
}
this.mFeedBackEditText.addTextChangedListener(this);
}
示例10: changeViewPageHight
import android.widget.LinearLayout.LayoutParams; //导入依赖的package包/类
@SuppressLint({"NewApi"})
private void changeViewPageHight() {
final int w = MeasureSpec.makeMeasureSpec(0, 0);
final int h = MeasureSpec.makeMeasureSpec(0, 0);
this.mRegisterViewPager.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener(this) {
final /* synthetic */ RegisterActivity this$0;
public void onGlobalLayout() {
if (VERSION.SDK_INT >= 16) {
this.this$0.mRegisterViewPager.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
this.this$0.mRegisterViewPager.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
View view = this.this$0.mRegisterViewPager.getChildAt(this.this$0.mRegisterViewPager.getCurrentItem());
view.measure(w, h);
LayoutParams params = new LayoutParams(-1, -2);
params.height = view.getMeasuredHeight();
this.this$0.mRegisterViewPager.setLayoutParams(params);
}
});
}
示例11: updateUI
import android.widget.LinearLayout.LayoutParams; //导入依赖的package包/类
public void updateUI() {
this.recoAppName.setText(this.mrecoApp.getName());
String[] split = this.mrecoApp.getDesc().split("/");
if (split.length == 2) {
this.reco_desp.setPadding(0, 0, 0, 60);
}
for (CharSequence text : split) {
TextView tv = new TextView(this);
tv.setLayoutParams(new LayoutParams(-1, -1, 1.0f));
tv.setShadowLayer(3.0f, 3.0f, 1.0f, 2131493090);
tv.setTextColor(-1);
tv.setGravity(1);
tv.setText(text);
tv.setTextSize(18.0f);
this.reco_desp.addView(tv);
}
}
示例12: addTab
import android.widget.LinearLayout.LayoutParams; //导入依赖的package包/类
protected void addTab(int index, CharSequence text, int iconResId) {
TabView tabView = new TabView(this, getContext(), text);
tabView.setIndex(index);
tabView.setTextSize(1, 15.0f);
tabView.setFocusable(true);
tabView.setOnClickListener(this.mTabClickListener);
if (iconResId != 0) {
tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
}
int width = this.mMeanWidth == -1 ? tabView.getCustomWidth() : this.mMeanWidth;
if (this.mMeanWidth != -1) {
tabView.setSize(this.mMeanWidth, UIsUtils.dipToPx(43.0f));
}
tabView.setLayoutParams(new LayoutParams(width, tabView.getCustomHeight(), 17.0f));
LinearLayout linearLayout = new LinearLayout(this.mContext);
linearLayout.setOrientation(1);
linearLayout.setGravity(17);
linearLayout.setLayoutParams(new LayoutParams(width, -2, 17.0f));
linearLayout.addView(tabView);
View imageView = new View(this.mContext);
imageView.setLayoutParams(new LayoutParams(UIsUtils.dipToPx(76.0f), UIsUtils.dipToPx(2.0f), 17.0f));
imageView.setBackgroundColor(this.mContext.getResources().getColor(2131493202));
linearLayout.addView(imageView);
this.mTabLayout.addView(linearLayout);
}
示例13: getBodyBottom
import android.widget.LinearLayout.LayoutParams; //导入依赖的package包/类
private LinearLayout getBodyBottom() {
LinearLayout llBottom = new LinearLayout(getContext());
llBottom.setLayoutParams(new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
String platform = String.valueOf(reqData.get("platform"));
LinearLayout line = getAtLine(platform);
if (line != null) {
llBottom.addView(line);
}
// 字数统计
tvCounter = new TextView(getContext());
tvCounter.setText(String.valueOf(MAX_TEXT_COUNT));
tvCounter.setTextColor(0xffcfcfcf);
tvCounter.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
tvCounter.setTypeface(Typeface.DEFAULT_BOLD);
LinearLayout.LayoutParams lpCounter = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lpCounter.gravity = Gravity.CENTER_VERTICAL;
tvCounter.setLayoutParams(lpCounter);
llBottom.addView(tvCounter);
return llBottom;
}
示例14: onCreate
import android.widget.LinearLayout.LayoutParams; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
callId = intent.getStringExtra("callId");
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.setPadding(20, 20, 20, 20);
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
editText = new EditText(this);
editText.setHint(R.string.demo_b_username_hint);
editText.setText("billy");
layout.addView(editText, params);
Button button = new Button(this);
button.setText(R.string.demo_b_click_login);
button.setOnClickListener(this);
layout.addView(button, params);
setContentView(layout);
}
示例15: setFullScreenForSmallLandscape
import android.widget.LinearLayout.LayoutParams; //导入依赖的package包/类
protected void setFullScreenForSmallLandscape() {
int nScreenSizeCategory = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
int nScreenOrientation = getResources().getConfiguration().orientation;
if (nScreenOrientation != Configuration.ORIENTATION_LANDSCAPE) {
if (nScreenSizeCategory == Configuration.SCREENLAYOUT_SIZE_SMALL) { // making it full screen in portrait mode if small screen
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
} else {
if (nScreenSizeCategory == Configuration.SCREENLAYOUT_SIZE_SMALL
|| nScreenSizeCategory == Configuration.SCREENLAYOUT_SIZE_NORMAL) { // making it full screen in landscape mode if small or normal screen
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
}