List of usage examples for android.widget LinearLayout VERTICAL
int VERTICAL
To view the source code for android.widget LinearLayout VERTICAL.
Click Source Link
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.LayoutParams getWeightParams(float weight, int orientation) { LinearLayout.LayoutParams params = null; if (orientation != LinearLayout.VERTICAL) { // HORIZONTAL params = new LinearLayout.LayoutParams(0, LayoutParams.FILL_PARENT, weight); } else {//from w ww. j a v a 2 s . co m params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 0, weight); } return params; }
From source file:Main.java
public static void setWeight(View view, float weight, int orientation) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) view.getLayoutParams(); if (params == null) { if (orientation != LinearLayout.VERTICAL) { params = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT); } else {// w w w .java 2 s. co m params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 0); } } params.weight = weight; view.setLayoutParams(params); }
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 ww w. j a va 2 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 w w . j a v a 2 s . co m*/ 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 va 2 s. co m 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:com.luskprog.doubledpager.DoublePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { MainActivity act = (MainActivity) getActivity(); mIsTheProperOrientation = act.isLandscape(); // layout containing two TextView simulating two Pages text LinearLayout ll = new LinearLayout(getActivity()); ll.setOrientation(LinearLayout.VERTICAL); TextView tv1 = new TextView(getActivity()); TextView tv2 = new TextView(getActivity()); if (mIsTheProperOrientation) { // get the data array as we have to show text for two pages. String[] data = ((MainActivity) getActivity()).getDoublePage(getArguments().getInt("position")); tv1.setText(data[0]);//from w w w .ja va2s . c o m tv2.setText(data[1]); } ll.addView(tv1); ll.addView(tv2); 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);// ww w.j a va2 s . 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.android.messaging.ui.CustomHeaderViewPager.java
public CustomHeaderViewPager(final Context context, final AttributeSet attrs) { super(context, attrs); final LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.custom_header_view_pager, this, true); setOrientation(LinearLayout.VERTICAL); mTabstrip = (ViewPagerTabs) findViewById(R.id.tab_strip); mViewPager = (ViewPager) findViewById(R.id.pager); TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true); mDefaultTabStripSize = context.getResources().getDimensionPixelSize(tv.resourceId); }
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 w w . j a v a2s . 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); }