List of usage examples for android.widget LinearLayout setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.owncloud.android.ui.activity.FirstRunActivity.java
private void setSlideshowSize(boolean isLandscape) { boolean isProviderOrOwnInstallationVisible = getResources() .getBoolean(R.bool.show_provider_or_own_installation); LinearLayout buttonLayout = findViewById(R.id.buttonLayout); LinearLayout.LayoutParams layoutParams; buttonLayout.setOrientation(isLandscape ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL); LinearLayout bottomLayout = findViewById(R.id.bottomLayout); if (isProviderOrOwnInstallationVisible) { layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } else {//from w ww . j a va 2 s . c o m layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.convertDpToPixel(isLandscape ? 100f : 150f, this)); } bottomLayout.setLayoutParams(layoutParams); }
From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java
private LinearLayout make_Active_Tab(String text, Drawable dr) { LinearLayout ll = new LinearLayout(this); ll.setPadding(0, 0, 2, 1);/*w ww. j a va 2 s . co m*/ ll.setBackgroundColor(Color.GRAY); ll.setTag("ll"); ll.setOrientation(LinearLayout.VERTICAL); ll.setLayoutParams( new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1)); //------ Text TextView tv = new TextView(this); tv.setBackgroundColor(Color.TRANSPARENT); tv.setTag("tv"); ll.addView(tv); // ------ hbar View hbar = new View(this); hbar.setTag("hbar"); hbar.setLayoutParams( new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10)); ll.addView(hbar); //////////////////////////////////////// return ActivateColorize(ll, text, dr); }
From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java
private LinearLayout make_Inactive_Tab(String text, Drawable dr) { LinearLayout ll = new LinearLayout(this); ll.setPadding(0, 0, 2, 1);/*from w w w . jav a 2s.co m*/ ll.setBackgroundColor(Color.GRAY); ll.setTag("ll"); ll.setOrientation(LinearLayout.VERTICAL); ll.setLayoutParams( new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1)); //------ Text TextView tv = new TextView(this); tv.setBackgroundColor(Color.TRANSPARENT); tv.setTag("tv"); ll.addView(tv); // ------ hbar View hbar = new View(this); hbar.setTag("hbar"); hbar.setLayoutParams( new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10)); ll.addView(hbar); ///////////////////////////////////// return InActivateColorize(ll, text, dr); }
From source file:ng.kingsley.android.widget.CollectionView.java
private View makeNewItemRow(RowComputeResult rowInfo) { LinearLayout ll = new LinearLayout(getContext()); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); ll.setOrientation(LinearLayout.HORIZONTAL); ll.setLayoutParams(params); int i;/*w w w. ja va 2 s. c o m*/ for (i = 0; i < rowInfo.group.mDisplayCols; i++) { View view = getItemView(rowInfo, i, null, ll); LinearLayout.LayoutParams viewLayoutParams = setupLayoutParams(view); ll.addView(view, viewLayoutParams); } return ll; }
From source file:org.telegram.ui.Cells.UserControlCell.java
public UserControlCell(Context context, int padding) { super(context); avatarImageView = new BackupImageView(context); avatarImageView.setRoundRadius(AndroidUtilities.dp(24)); addView(avatarImageView);/* w ww .ja va2 s . com*/ LayoutParams layoutParams = (LayoutParams) avatarImageView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(48); layoutParams.height = AndroidUtilities.dp(48); layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(16); layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(padding) : 0; layoutParams.topMargin = AndroidUtilities.dp(8); avatarImageView.setLayoutParams(layoutParams); avatarDrawable = new AvatarDrawable(); nameTextView = new TextView(context); nameTextView.setTextColor(0xff212121); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17); nameTextView.setLines(1); nameTextView.setMaxLines(1); nameTextView.setSingleLine(true); nameTextView.setEllipsize(TextUtils.TruncateAt.END); nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(nameTextView); layoutParams = (LayoutParams) nameTextView.getLayoutParams(); layoutParams.width = LayoutParams.WRAP_CONTENT; layoutParams.height = LayoutParams.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? RIGHT_MARGIN : (68)); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? (68) : RIGHT_MARGIN); layoutParams.topMargin = AndroidUtilities.dp(10.5f); layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; nameTextView.setLayoutParams(layoutParams); messageTextView = new TextView(context); messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); messageTextView.setLines(1); messageTextView.setMaxLines(1); messageTextView.setSingleLine(true); messageTextView.setEllipsize(TextUtils.TruncateAt.END); messageTextView .setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(messageTextView); layoutParams = (LayoutParams) messageTextView.getLayoutParams(); layoutParams.width = LayoutParams.WRAP_CONTENT; layoutParams.height = LayoutParams.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? RIGHT_MARGIN : (68)); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? (68) : RIGHT_MARGIN); layoutParams.topMargin = AndroidUtilities.dp(33.5f); layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT; messageTextView.setLayoutParams(layoutParams); imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER); addView(imageView); layoutParams = (LayoutParams) imageView.getLayoutParams(); layoutParams.width = LayoutParams.WRAP_CONTENT; layoutParams.height = LayoutParams.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16); layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0); layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL; imageView.setLayoutParams(layoutParams); imageView.setVisibility(View.GONE); LinearLayout buttonContainer = new LinearLayout(context); addView(buttonContainer); layoutParams = (LayoutParams) buttonContainer.getLayoutParams(); layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.height = AndroidUtilities.dp(60); layoutParams.rightMargin = AndroidUtilities.dp(16); layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL; buttonContainer.setLayoutParams(layoutParams); ApproveBtn = new TextView(context); ApproveBtn.setBackgroundDrawable(getResources().getDrawable(R.drawable.approve_bg)); ApproveBtn.setTextColor(getResources().getColor(android.R.color.white)); ApproveBtn.setText(getResources().getString(R.string.approve_join_group)); buttonContainer.addView(ApproveBtn); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ApproveBtn.getLayoutParams(); lp.width = AndroidUtilities.dp(0); lp.weight = 1; lp.height = LayoutParams.WRAP_CONTENT; lp.gravity = Gravity.CENTER_VERTICAL; lp.rightMargin = AndroidUtilities.dp(2); ApproveBtn.setLayoutParams(lp); ApproveBtn.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8)); IgnoreBtn = new TextView(context); IgnoreBtn.setBackgroundDrawable(getResources().getDrawable(R.drawable.ignore_bg)); IgnoreBtn.setTextColor(getResources().getColor(android.R.color.white)); IgnoreBtn.setText(getResources().getString(R.string.ignore_join_group)); buttonContainer.addView(IgnoreBtn); lp = (LinearLayout.LayoutParams) IgnoreBtn.getLayoutParams(); lp.width = AndroidUtilities.dp(0); lp.weight = 1; lp.height = LayoutParams.WRAP_CONTENT; lp.gravity = Gravity.CENTER_VERTICAL; lp.leftMargin = AndroidUtilities.dp(2); IgnoreBtn.setLayoutParams(lp); IgnoreBtn.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8)); }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * @return//from w w w .j a v a2s . c o m */ private LinearLayout createTableRow(int orientation) { LinearLayout row = new LinearLayout(this); row.setPadding(0, 0, 0, 5); row.setOrientation(orientation); row.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); return row; }
From source file:fr.cph.chicago.activity.StationActivity.java
/** * Draw line// w w w.j a v a 2s . c o m * * @param eta * the eta */ private final void drawLine3(final Eta eta) { TrainLine line = eta.getRouteName(); Stop stop = eta.getStop(); int line3Padding = (int) getResources().getDimension(R.dimen.activity_station_stops_line3); Integer viewId = mIds.get(line.toString() + "_" + stop.getDirection().toString()); // viewId might be not there if CTA API provide wrong data if (viewId != null) { LinearLayout line3View = (LinearLayout) findViewById(viewId); Integer id = mIds.get(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName()); if (id == null) { LinearLayout insideLayout = new LinearLayout(this); insideLayout.setOrientation(LinearLayout.HORIZONTAL); insideLayout.setLayoutParams(mParamsStop); int newId = Util.generateViewId(); insideLayout.setId(newId); mIds.put(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName(), newId); TextView stopName = new TextView(this); stopName.setText(eta.getDestName() + ": "); stopName.setTextColor(getResources().getColor(R.color.grey)); stopName.setPadding(line3Padding, 0, 0, 0); insideLayout.addView(stopName); TextView timing = new TextView(this); timing.setText(eta.getTimeLeftDueDelay() + " "); timing.setTextColor(getResources().getColor(R.color.grey)); timing.setLines(1); timing.setEllipsize(TruncateAt.END); insideLayout.addView(timing); line3View.addView(insideLayout); } else { LinearLayout insideLayout = (LinearLayout) findViewById(id); TextView timing = (TextView) insideLayout.getChildAt(1); timing.setText(timing.getText() + eta.getTimeLeftDueDelay() + " "); } line3View.setVisibility(View.VISIBLE); } }
From source file:org.telegram.ui.ChangePhoneHelpActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); TLRPC.User user = UserConfig.getCurrentUser(); String value;//from w w w . j a v a 2 s . c o m if (user != null && user.phone != null && user.phone.length() != 0) { value = PhoneFormat.getInstance().format("+" + user.phone); } else { value = LocaleController.getString("NumberUnknown", R.string.NumberUnknown); } actionBar.setTitle(value); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); fragmentView = new RelativeLayout(context); fragmentView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); RelativeLayout relativeLayout = (RelativeLayout) fragmentView; ScrollView scrollView = new ScrollView(context); relativeLayout.addView(scrollView); RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) scrollView.getLayoutParams(); layoutParams3.width = LayoutHelper.MATCH_PARENT; layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); scrollView.setLayoutParams(layoutParams3); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setPadding(0, AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20)); scrollView.addView(linearLayout); ScrollView.LayoutParams layoutParams = (ScrollView.LayoutParams) linearLayout.getLayoutParams(); layoutParams.width = ScrollView.LayoutParams.MATCH_PARENT; layoutParams.height = ScrollView.LayoutParams.WRAP_CONTENT; linearLayout.setLayoutParams(layoutParams); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.phone_change); linearLayout.addView(imageView); LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) imageView.getLayoutParams(); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; imageView.setLayoutParams(layoutParams2); TextView textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setGravity(Gravity.CENTER_HORIZONTAL); //textView.setTextColor(0xff212121); try { textView.setText(AndroidUtilities .replaceTags(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp))); } catch (Exception e) { FileLog.e("tmessages", e); textView.setText(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp)); } linearLayout.addView(textView); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams(); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; layoutParams2.leftMargin = AndroidUtilities.dp(20); layoutParams2.rightMargin = AndroidUtilities.dp(20); layoutParams2.topMargin = AndroidUtilities.dp(56); textView.setLayoutParams(layoutParams2); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); textView.setGravity(Gravity.CENTER_HORIZONTAL); textView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent) /*0xff4d83b3*/); textView.setText(LocaleController.getString("PhoneNumberChange", R.string.PhoneNumberChange)); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(12), AndroidUtilities.dp(16), AndroidUtilities.dp(12)); textView.setBackground(context.getDrawable(R.drawable.list_selector)); linearLayout.addView(textView); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams(); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; layoutParams2.leftMargin = AndroidUtilities.dp(20); layoutParams2.rightMargin = AndroidUtilities.dp(20); layoutParams2.topMargin = AndroidUtilities.dp(46); textView.setLayoutParams(layoutParams2); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.getString("PhoneNumberAlert", R.string.PhoneNumberAlert)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { presentFragment(new ChangePhoneActivity(), true); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } }); return fragmentView; }
From source file:org.apache.cordova.SplashScreenInternal.java
/** * Shows the splash screen over the full Activity *//*from w w w . j av a2s. c o m*/ @SuppressWarnings("deprecation") private void showSplashScreen(final boolean hideAfterDelay) { final int splashscreenTime = preferences.getInteger("SplashScreenDelay", 3000); final int drawableId = preferences.getInteger("SplashDrawableId", 0); // If the splash dialog is showing don't try to show it again if (this.splashDialog != null && splashDialog.isShowing()) { return; } if (drawableId == 0 || (splashscreenTime <= 0 && hideAfterDelay)) { return; } cordova.getActivity().runOnUiThread(new Runnable() { public void run() { // Get reference to display Display display = cordova.getActivity().getWindowManager().getDefaultDisplay(); Context context = webView.getContext(); // Create the layout for the dialog LinearLayout root = new LinearLayout(context); root.setMinimumHeight(display.getHeight()); root.setMinimumWidth(display.getWidth()); root.setOrientation(LinearLayout.VERTICAL); // TODO: Use the background color of the webview's parent instead of using the // preference. root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK)); root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0F)); root.setBackgroundResource(drawableId); // Create and show the dialog splashDialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar); // check to see if the splash screen should be full screen if ((cordova.getActivity().getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) { splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } splashDialog.setContentView(root); splashDialog.setCancelable(false); splashDialog.show(); // Set Runnable to remove splash screen just in case if (hideAfterDelay) { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { removeSplashScreen(); } }, splashscreenTime); } } }); }