Best code examples for Android LinearLayout class (android.widget.LinearLayout)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android LinearLayout class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android LinearLayout examples from Open Source projects
This code example shows how to use the following methods: setId, setLayoutParams, setOrientation
61:	LinearLayout layout = new LinearLayout(this); 
62:	layout.setOrientation(LinearLayout.VERTICAL); 
63:	layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 
-
65:	layout.setId(FRAGMENT_ID); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setBackgroundColor, setLayoutParams, addView, setOrientation
78:	root = new LinearLayout(this); 
79:	root.setOrientation(LinearLayout.VERTICAL); 
80:	root.setBackgroundColor(Color.BLACK); 
81:	root.setLayoutParams(containerParams); 
-
111:	root.addView(appView); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setTag, addView, setOrientation
50:	LinearLayout layout=new LinearLayout(ctxt); 
-
58:	layout.setOrientation(LinearLayout.HORIZONTAL); 
-
78:	layout.addView(rate); 
79:	layout.addView(guts); 
-
81:	wrap=new ViewWrapper(layout); 
-
83:	layout.setTag(wrap); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: addView, setOrientation, addView
47:	LinearLayout layout = new LinearLayout(this); 
48:	layout.setOrientation(LinearLayout.VERTICAL); 
-
54:	layout.addView(editText); 
-
56:	((ScrollView) mRootView).addView(layout); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setBackgroundDrawable, addView, addView
147:	containerView = new LinearLayout(context); 
148:	containerView.addView(contentView); 
149:	containerView.setBackgroundDrawable(background); 
150:	getWindowManager().addView(containerView, null); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: requestLayout, addView, removeAllViews
150:	view.removeAllViews(); 
-
153:	view.addView(progress); 
154:	view.addView(label); 
155:	view.requestLayout(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: addView, setOrientation
34:	final LinearLayout layout = new LinearLayout(this); 
35:	layout.setOrientation(LinearLayout.VERTICAL); 
-
38:	layout.addView(view, new LinearLayout.LayoutParams(PathView.SIZE, PathView.SIZE)); 
-
41:	layout.addView(view, new LinearLayout.LayoutParams(PathView.SIZE, PathView.SIZE)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setId, setLayoutParams, setVisibility, addView, setGravity
81:	mFooterView = new LinearLayout(context); 
82:	mFooterView.setId(INTERNAL_FOOTER_ID); 
83:	mFooterView.setGravity(Gravity.CENTER); 
84:	mFooterView.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT)); 
-
93:	mFooterView.addView(mProgress); 
-
102:	mFooterView.addView(mStandardEmptyView, new LayoutParams(MATCH_PARENT, MATCH_PARENT)); 
-
195:	mFooterView.setVisibility(View.VISIBLE); 
-
197:	mFooterView.setVisibility(View.GONE); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: addView, setOrientation
43:	LinearLayout container = new LinearLayout(this); 
44:	container.setOrientation(LinearLayout.VERTICAL); 
-
47:	container.addView(slider); 
-
56:	container.addView(frame); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: addView, setOrientation, addView
48:	LinearLayout layout = new LinearLayout(this); 
49:	layout.setOrientation(LinearLayout.VERTICAL); 
-
58:	layout.addView(button); 
59:	layout.addView(editText); 
-
61:	((ScrollView) mRootView).addView(layout); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setBackgroundResource, setLayoutParams, addView, setGravity, setOrientation
100:	LinearLayout linearLayout = new LinearLayout(context); 
101:	linearLayout.setOrientation(LinearLayout.HORIZONTAL); 
102:	linearLayout.setGravity(Gravity.CENTER); 
-
106:	linearLayout.setLayoutParams(lParams); 
107:	linearLayout.addView(textView); 
-
109:	linearLayout.setBackgroundResource(bgres); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setPadding, addView, setOrientation
44:	LinearLayout layout = new LinearLayout(mContext); 
45:	layout.setOrientation(LinearLayout.VERTICAL); 
46:	layout.setPadding(6,6,6,6); 
-
51:	layout.addView(mSplashText); 
-
59:	layout.addView(mValueText, params); 
-
63:	layout.addView(mSeekBar, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setLayoutParams, addView, setOrientation
76:	LinearLayout tabRootView = new LinearLayout( activity ); 
77:	tabRootView.setOrientation( LinearLayout.VERTICAL ); 
78:	tabRootView.setLayoutParams( 
-
82:	tabRootView.addView( createTabWidget( activity ) ); 
83:	tabRootView.addView( createTabContent( activity ) ); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: addView, setOrientation
56:	button.setOnClickListener(new View.OnClickListener() { 
-
75:	root.addView(child, params); 
-
83:	LinearLayout layout = new LinearLayout(this); 
84:	layout.setOrientation(LinearLayout.VERTICAL); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setLayoutParams, addView, setOrientation
46:	final LinearLayout layout = new LinearLayout(this); 
47:	layout.setOrientation(LinearLayout.HORIZONTAL); 
48:	layout.setLayoutParams(new ViewGroup.LayoutParams( 
-
58:	layout.addView(leftColumn); 
-
63:	layout.addView(middleColumn); 
-
68:	layout.addView(rightColumn); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getContext, setBackgroundDrawable, setPadding, setGravity
246:	Theme theme = ThemeUtil.createTheme(llProfileHeader.getContext()); 
247:	llProfileHeader.setBackgroundDrawable(theme.getDrawable("selector_bg_profile_header")); 
-
249:	llProfileHeader.setPadding(padding8, padding8, padding8, padding8); 
250:	llProfileHeader.setGravity(Gravity.CENTER); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: addView
71:	LinearLayout mainLayout = new LinearLayout(this); 
72:	mainLayout.addView(mVideoView, new LinearLayout.LayoutParams( 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setPadding, addView, setOrientation
105:	final LinearLayout view = new LinearLayout(context); 
106:	view.setOrientation(LinearLayout.VERTICAL); 
-
111:	view.addView(mColorPicker, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 
112:	view.setPadding(Math.round(mColorPicker.getDrawingOffset()), 0, Math.round(mColorPicker.getDrawingOffset()), 0); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: addView, setOrientation
326:	LinearLayout hintContainer = new LinearLayout(context); 
327:	hintContainer.setOrientation(LinearLayout.VERTICAL); 
-
335:	hintContainer.addView(dropDownView, hintParams); 
336:	hintContainer.addView(hintView); 
-
340:	hintContainer.addView(hintView); 
341:	hintContainer.addView(dropDownView, hintParams); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setPadding, addView, setOrientation
69:	LinearLayout layout = new LinearLayout(mContext); 
70:	layout.setOrientation(LinearLayout.VERTICAL); 
71:	layout.setPadding(6, 6, 6, 6); 
-
76:	layout.addView(mSplashText); 
-
83:	layout.addView(mValueText, params); 
-
87:	layout.addView(mSeekBar, new LinearLayout.LayoutParams( 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setLayoutParams, addView, setOrientation
46:	mLayout = new LinearLayout(this); 
47:	mLayout.setOrientation(LinearLayout.VERTICAL); 
48:	mLayout.setLayoutParams(new ViewGroup.LayoutParams( 
-
73:	mLayout.addView(mEditText); 
74:	mLayout.addView(mButton1); 
75:	mLayout.addView(mButton2); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getVisibility, setVisibility
30:	if (llEmotion.getVisibility() == View.GONE) { 
31:	llEmotion.setVisibility(View.VISIBLE); 
-
42:	if (llEmotion.getVisibility() == View.VISIBLE) { 
43:	llEmotion.setVisibility(View.GONE); 
-
54:	if (llEmotion.getVisibility() == View.GONE) { 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getPaddingBottom, getPaddingLeft, getPaddingRight, setPadding
238:	mRefreshView.setPadding( 
239:	mRefreshView.getPaddingLeft(), mRefreshOriginalTopPadding + topPadding, 
240:	mRefreshView.getPaddingRight(), mRefreshView.getPaddingBottom()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: addView, setOrientation
56:	button.setOnClickListener(new View.OnClickListener() { 
-
75:	root.addView(child, params); 
-
83:	LinearLayout layout = new LinearLayout(this); 
84:	layout.setOrientation(LinearLayout.VERTICAL); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setBackgroundDrawable, setLayoutParams, addView, setGravity
67:	LinearLayout toolbar = new LinearLayout(context); 
-
71:	toolbar.setLayoutParams(toolbarParams); 
72:	toolbar.setGravity(Gravity.CENTER_VERTICAL|Gravity.RIGHT); 
73:	toolbar.setBackgroundDrawable(viewBg); 
-
83:	toolbar.addView(button); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getLeft, invalidate, offsetLeftAndRight
89:	final int interBackRelPosition = interBackPosition - mBackLayout.getLeft(); 
-
91:	mBackLayout.offsetLeftAndRight(interBackRelPosition); 
92:	mBackLayout.invalidate(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getOrientation, setOrientation
42:	assertThat(linearLayout.getOrientation()).isEqualTo(LinearLayout.HORIZONTAL); 
43:	linearLayout.setOrientation(LinearLayout.VERTICAL); 
44:	assertThat(linearLayout.getOrientation()).isEqualTo(LinearLayout.VERTICAL); 
45:	linearLayout.setOrientation(LinearLayout.HORIZONTAL); 
46:	assertThat(linearLayout.getOrientation()).isEqualTo(LinearLayout.HORIZONTAL); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getId, setId, setLayoutParams, addView
201:	LinearLayout ll1 = new LinearLayout(getContext()); 
202:	ll1.setId(generateViewId()); 
-
208:	ll1.setLayoutParams(lp); 
209:	ll1.addView(this.tvColorLabel); 
210:	ll1.addView(this.etColor); 
-
213:	return ll1.getId(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: addView, setOrientation
34:	final LinearLayout layout = new LinearLayout(this); 
35:	layout.setOrientation(LinearLayout.VERTICAL); 
-
38:	layout.addView(view, new LinearLayout.LayoutParams(PathView.SIZE, PathView.SIZE)); 
-
41:	layout.addView(view, new LinearLayout.LayoutParams(PathView.SIZE, PathView.SIZE)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setPadding, addView, setOrientation
102:	final LinearLayout layout = new LinearLayout(context); 
103:	layout.setOrientation(LinearLayout.VERTICAL); 
104:	layout.setPadding(6, 6, 6, 6); 
-
110:	layout.addView(dialogTextView); 
-
118:	layout.addView(valueTextView, params); 
-
122:	layout.addView(seekBar, new LinearLayout.LayoutParams( 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setLayoutParams, setMinimumWidth, setPadding, addView, setOrientation
50:	LinearLayout layout = new LinearLayout(context); 
51:	layout.setOrientation(LinearLayout.VERTICAL); 
52:	layout.setLayoutParams(new 
-
55:	layout.setMinimumWidth(400); 
56:	layout.setPadding(20, 20, 20, 20); 
-
62:	layout.addView(edit_text); 
-
74:	layout.addView(seek_bar); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setBackgroundColor, addView, setContentView, setGravity
235:	LinearLayout layout = new LinearLayout(this); 
236:	layout.setBackgroundColor(0xFF000000); 
237:	layout.setGravity(Gravity.CENTER); 
238:	layout.addView(gameView); 
-
240:	getWindow().setContentView(layout, params); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setLayoutParams, addView, setOrientation
59:	LinearLayout outerContainer = new LinearLayout(context); 
-
61:	outerContainer.setLayoutParams(layoutParams); 
62:	outerContainer.setOrientation(LinearLayout.VERTICAL); 
63:	outerContainer.addView(subView); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: addView, getChildAt, getChildCount, setOrientation
123:	if (linearLayout.getChildCount() == 1) { 
124:	View child = linearLayout.getChildAt(0); 
-
160:	linearLayout.setOrientation(LinearLayout.HORIZONTAL); 
161:	linearLayout.addView(imageView, 0); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setLayoutParams, addView, setOrientation
76:	LinearLayout layout = new LinearLayout(context); 
77:	layout.setOrientation(LinearLayout.VERTICAL); 
78:	layout.setLayoutParams(params); 
-
83:	layout.addView(mValueText); 
-
91:	layout.addView(seekBar); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setLayoutParams, setPadding, addView
237:	mEditTextlayout = new LinearLayout(getContext()); 
238:	mEditTextlayout.setLayoutParams(new ViewGroup.LayoutParams( 
-
240:	mEditTextlayout.setPadding(dip, dip, dip, dip); 
241:	mEditTextlayout.addView(mEditText); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setPadding, addView, setOrientation
42:	LinearLayout layout = new LinearLayout(mContext); 
43:	layout.setOrientation(LinearLayout.VERTICAL); 
44:	layout.setPadding(6,6,6,6); 
-
49:	layout.addView(mSplashText); 
-
57:	layout.addView(mValueText, params); 
-
61:	layout.addView(mSeekBar, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setBackgroundColor, setPadding, addView, setOrientation
79:	buttonHolder = new LinearLayout(context); 
80:	buttonHolder.setBackgroundColor(0xf08080); 
81:	buttonHolder.setOrientation(LinearLayout.HORIZONTAL); 
82:	buttonHolder.setPadding(6, 3, 3, 3); 
-
95:	buttonHolder.addView(btn, new LinearLayout.LayoutParams( 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getPaddingLeft, getPaddingRight, getWidth
308:	mSliderMoveWidth = mOuterLayout.getWidth() - mSlider.getBackground().getIntrinsicWidth() + (2 * SHADOW_PADDING); 
-
311:	mBackMoveWidth = mInverseSliderWidth - mOuterLayout.getWidth() + mOuterLayout.getPaddingRight() + mOuterLayout.getPaddingLeft();// - (2 * SHADOW_PADDING); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setPadding, addView, setOrientation
96:	LinearLayout layout = new LinearLayout(context); 
97:	layout.setOrientation(LinearLayout.HORIZONTAL); 
98:	layout.setPadding(4, 2, 4, 2); 
99:	layout.addView(iv); 
100:	layout.addView(tv); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setPadding, addView, setOrientation
45:	LinearLayout layout = new LinearLayout(mContext); 
46:	layout.setOrientation(LinearLayout.VERTICAL); 
47:	layout.setPadding(6, 6, 6, 6); 
-
52:	layout.addView(mSplashText); 
-
60:	layout.addView(mValueText, params); 
-
64:	layout.addView(mSeekBar, new LinearLayout.LayoutParams( 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getVisibility, setVisibility, startAnimation
123:	if (mIndicator.getVisibility() == View.VISIBLE) return; 
124:	mIndicator.setVisibility(View.VISIBLE); 
125:	mIndicator.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setPadding, addView, setGravity, setOrientation
107:	LinearLayout lLayout = new LinearLayout(this.mContext); 
108:	lLayout.setOrientation(LinearLayout.VERTICAL); 
109:	lLayout.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); 
110:	lLayout.setPadding(10, 10, 10, 10); 
-
122:	lLayout.addView(lImageView, new LinearLayout.LayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT))); 
123:	lLayout.addView(lView); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setBackgroundDrawable, setLayoutParams, addView
64:	LinearLayout layout = new LinearLayout(getContext()); 
-
67:	layout.setLayoutParams(masterParams); 
68:	layout.setBackgroundDrawable(((Drawables)container.getBean("drawables")).getDrawable("slate.png", true, true, true)); 
-
70:	layout.addView(scrollView); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setPadding, addView, setGravity, setOrientation
47:	LinearLayout layout = new LinearLayout(mContext); 
48:	layout.setOrientation(LinearLayout.VERTICAL); 
49:	layout.setPadding(6,6,6,6); 
50:	layout.setGravity(Gravity.CENTER); 
-
56:	layout.addView(mTitleText); 
-
60:	layout.addView(mVersionText); 
-
68:	layout.addView(mScrollView); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: requestFocus, setFocusable, setFocusableInTouchMode, setId, setLayoutParams
34:	View layout = new LinearLayout(this); 
35:	layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 
36:	layout.setId(CONTENT_VIEW_ID); 
-
38:	layout.setOnKeyListener(new OnKeyListener() { 
-
55:	layout.setFocusable(true); 
56:	layout.setFocusableInTouchMode(true); 
57:	layout.requestFocus(); 
Full Snippet Info
7
CodeRank
Related Android LinearLayout Questions & Answers:
Other Android LinearLayout Examples
66:	        ViewGroup owner = (ViewGroup) view.getParent();
67:	        owner.removeView(view);
68:	        LinearLayout container = (LinearLayout) v;
69:	        container.addView(view);
70:	        view.setVisibility(View.VISIBLE);
-
66:	        ViewGroup owner = (ViewGroup) view.getParent();
67:	        owner.removeView(view);
68:	        LinearLayout container = (LinearLayout) v;
69:	        container.addView(view);
70:	        view.setVisibility(View.VISIBLE);

Read More

10:	public class MainActivity extends Activity {
11:	
12:		LinearLayout llStats;
13:		TextView txtPlayCount, txtEarned;
14:	
-
18:			setContentView(R.layout.activity_main);
19:	
20:			llStats = (LinearLayout) findViewById(R.id.llStats);
21:			txtPlayCount = (TextView) findViewById(R.id.txtNowPlaying);
22:			txtEarned = (TextView) findViewById(R.id.txtEarned);

Read More

36:		private ImageView imgProfilePic;
37:		private TextView txtName, txtEmail;
38:		private LinearLayout llProfileLayout;
39:	
40:		@Override
-
49:			txtName = (TextView) findViewById(R.id.txtName);
50:			txtEmail = (TextView) findViewById(R.id.txtEmail);
51:			llProfileLayout = (LinearLayout) findViewById(R.id.llProfile);
52:	
53:			// Button click listeners

Read More

57:		private ImageView imgProfilePic;
58:		private TextView txtName, txtEmail;
59:		private LinearLayout llProfileLayout;
60:	
61:		@Override
-
70:			txtName = (TextView) findViewById(R.id.txtName);
71:			txtEmail = (TextView) findViewById(R.id.txtEmail);
72:			llProfileLayout = (LinearLayout) findViewById(R.id.llProfile);
73:	
74:			// Button click listeners

Read More

See Code Examples for Android LinearLayout Methods: