List of usage examples for android.widget LinearLayout LinearLayout
public LinearLayout(Context context)
From source file:Main.java
public static LinearLayout setBaseLinearLayout(Context context) { LinearLayout root_layout = new LinearLayout(context); root_layout.setOrientation(LinearLayout.VERTICAL); return root_layout; }
From source file:Main.java
public static LinearLayout setProgressBarLayout(Activity activity) { LinearLayout progressBarLayout = new LinearLayout(activity); progressBarLayout.setGravity(Gravity.CENTER); ProgressBar spinner = new ProgressBar(activity); progressBarLayout.addView(spinner);/*from w ww . j av a 2 s.com*/ activity.addContentView(progressBarLayout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); return progressBarLayout; }
From source file:Main.java
public static View getTestFragmentView(Activity activity, OnClickListener clickListener) { LinearLayout v = new LinearLayout(activity); v.setBackgroundColor(Color.BLUE); v.setOrientation(LinearLayout.VERTICAL); TextView tv1 = new TextView(activity); TextView tv2 = new TextView(activity); Button b1 = new Button(activity); Button b2 = new Button(activity); Button b3 = new Button(activity); b1.setText("reload 1"); b2.setText("reload 2"); b3.setText("reload all"); b1.setId(1);/*from w ww . j a va2 s. c o m*/ b2.setId(2); b3.setId(3); tv1.setId(android.R.id.text1); tv2.setId(android.R.id.text2); b1.setOnClickListener(clickListener); b2.setOnClickListener(clickListener); b3.setOnClickListener(clickListener); v.addView(tv1); v.addView(tv2); v.addView(b1); v.addView(b2); v.addView(b3); return v; }
From source file:Main.java
private static LinearLayout createLLforAddToCalendar(final Context context, final CheckBox checkBox) { LinearLayout linearLayout = new LinearLayout(context); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(checkBox);//from w ww . j a v a 2 s . c om return linearLayout; }
From source file:com.art2cat.dev.moonlightnote.controller.settings.CommonSettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment if (getArguments() != null) { mType = getArguments().getInt("type"); }/*from ww w.ja v a 2s. c om*/ LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); linearLayout.setLayoutParams(params); ScrollView scrollView = new ScrollView(getActivity()); scrollView.setLayoutParams(params); linearLayout.addView(scrollView); TextView textView = new TextView(getActivity()); textView.setLayoutParams(params); int padding = getResources().getDimensionPixelOffset(R.dimen.padding); textView.setPadding(padding, padding, padding, padding); switch (mType) { case Constants.FRAGMENT_ABOUT: textView.setGravity(Gravity.CENTER); textView.setText(getContent()); getActivity().setTitle(R.string.settings_about); break; case Constants.FRAGMENT_LICENSE: textView.setGravity(Gravity.CENTER); textView.setText(getContent()); getActivity().setTitle(R.string.settings_license); break; case Constants.FRAGMENT_POLICY: textView.setGravity(Gravity.START); textView.setText(getContent()); getActivity().setTitle(R.string.settings_policy); break; } setHasOptionsMenu(true); scrollView.addView(textView); return linearLayout; }
From source file:biz.easymenu.easymenung.FoodMenuFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LinearLayout ll = new LinearLayout(getActivity()); ViewPager vp = new ViewPager(getActivity()); MenuPagerAdapter mpa = new MenuPagerAdapter(getActivity(), isDrinks); vp.setAdapter(mpa);/* w w w . java 2s .c o m*/ ll.addView(vp); return ll; }
From source file:com.alexive.graphicalutils.demo.CardsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //On a real project, you'd define the layout in an xml file this.mLinearLayout = new LinearLayout(this); this.mLinearLayout.setOrientation(LinearLayout.VERTICAL); ScrollView sv = new ScrollView(this); sv.addView(this.mLinearLayout); setContentView(sv);//from w w w. j av a 2s.c om this.mCardBuilder = new CardBuilder(CardBuilder.CardType.FULL_WIDTH_IMAGE); this.params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); int sixteenDP = ViewUtils.convertDPtoPixels(this, 16); this.params.setMargins(sixteenDP, sixteenDP / 2, sixteenDP, sixteenDP / 2); Drawable cardImage = ContextCompat.getDrawable(this, R.drawable.lisbon); this.mCardBuilder.setTitle("Card title here").setSubTitle("subtitle here") .addSupplementalAction(new CardBuilder.CardAction("A1", 1)) .addSupplementalAction(new CardBuilder.CardAction("A2", 2)).addActionClickListener(this) .setText("Text here! - To create a card like this use the " + "FULL_WIDTH_IMAGE card type") .setImage(cardImage); addCardToLayout(); this.mCardBuilder.setType(CardBuilder.CardType.IMAGE_AS_BACKGROUND).useLightTheme(false) //This one supports dark theme only .setText("Text here. Use IMAGE_AS_BACKGROUND for a card like this one"); addCardToLayout(); this.mCardBuilder.setType(CardBuilder.CardType.IMAGE_FILLS_WITH_ACTIONS_ON_LEFT).useLightTheme(true) .setText("Text here. IMAGE_FILLS_WITH_ACTIONS_ON_LEFT. " + "Notice this one doesn't display text"); addCardToLayout(); this.mCardBuilder.setType(CardBuilder.CardType.IMAGE_NEXT_TO_TITLE) .setText("Notice the previous one (IMAGE_FILLS_WITH_ACTIONS_ON_LEFT) " + "doesn't show any text. This one's a IMAGE_NEXT_TO_TITLE sample"); addCardToLayout(); this.mCardBuilder.reset(); //This clears the builder, you'll have to set it up again this.mCardBuilder.setType(CardBuilder.CardType.IMAGE_FILLS_WITH_ACTIONS_ON_LEFT).setImage(cardImage) .addSupplementalAction(new CardBuilder.CardAction( ContextCompat.getDrawable(this, R.drawable.ic_favorite_black_24dp), 3)) .addSupplementalAction(new CardBuilder.CardAction( ContextCompat.getDrawable(this, R.drawable.ic_info_outline_black_24dp), 4)) .addActionClickListener(this); addCardToLayout(); this.mCardBuilder.setType(CardBuilder.CardType.FULL_WIDTH_IMAGE).setTitle("Look, icons!") .setText("You can use icons as actions instead of text (or mix both)") .addSupplementalAction(new CardBuilder.CardAction("A5", 5)); addCardToLayout(); this.mCardBuilder.setType(CardBuilder.CardType.NO_IMAGE).setTitle("<Title>") .setText("This is the simplest one: NO_IMAGE"); addCardToLayout(); }
From source file:com.ternup.caddisfly.widget.FormWidget.java
public FormWidget(Context context, String name) { _layout = new LinearLayout(context); //_layout.setLayoutParams( FormActivity.defaultLayoutParams ); _layout.setOrientation(LinearLayout.VERTICAL); _property = name;//from w ww .j a v a 2s.com _displayText = name.replace("_", " "); _displayText = toTitleCase(_displayText); _label = new TextView(context); _label.setText(getDisplayText()); _label.setTextSize(context.getResources().getDimension(R.dimen.labelTextSize)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.bottomMargin = 0; params.topMargin = 10; _label.setLayoutParams(params); _label.setAllCaps(true); _label.setTextColor(context.getResources().getColor(R.color.labelTextColor)); _layout.addView(_label); }
From source file:com.actionbarsherlock.sample.demos.app.ActionBarActionItemCustomView.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem item = menu.add(0, android.R.id.copy, 0, "Test"); final int twentyDp = (int) (20 * getResources().getDisplayMetrics().density); TypedArray a = getTheme().obtainStyledAttributes(R.styleable.SherlockTheme); final int abHeight = a.getLayoutDimension(R.styleable.SherlockTheme_abHeight, LayoutParams.FILL_PARENT); a.recycle();/*w w w. ja v a2s. co m*/ LinearLayout l = new LinearLayout(this); l.setPadding(twentyDp, 0, twentyDp, 20); l.setBackgroundColor(0x55FF0000); TextView tv = new TextView(this); tv.setText("HI!!"); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, abHeight)); l.addView(tv); l.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(ActionBarActionItemCustomView.this, "Got custom action item click!", Toast.LENGTH_SHORT).show(); } }); item.setActionView(l); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); return super.onCreateOptionsMenu(menu); }
From source file:com.andryr.musicplayer.fragments.dialog.CreatePlaylistDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final View layout = LayoutInflater.from(getActivity()).inflate(R.layout.create_playlist_dialog, new LinearLayout(getActivity()), false); android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity()) .setTitle(R.string.create_playlist).setView(layout) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { EditText editText = (EditText) layout.findViewById(R.id.playlist_name); Playlists.createPlaylist(getActivity().getContentResolver(), editText.getText().toString()); if (mListener != null) { mListener.onPlaylistCreated(); }//w w w .j a v a2s. c om } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); return builder.create(); }