Best code examples for Android ViewGroup class (android.view.ViewGroup)

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

Android ViewGroup examples from Open Source projects
This code example shows how to use the following methods: setBackgroundColor, setLayoutParams, setVisibility, addView, addContentView
134:	mCustomViewContainer = new FrameLayout(activity); 
135:	mCustomViewContainer.setBackgroundColor(Color.BLACK); 
136:	mCustomViewContainer.setLayoutParams(params); 
137:	activity.getWindow().addContentView(mCustomViewContainer, params); 
-
139:	mCustomViewContainer.addView(view); 
-
142:	mCustomViewContainer.setVisibility(View.VISIBLE); 
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: measure, setBackground, layout, draw, dispatchOnPreDraw
76:	FrameLayout content = new FrameLayout(context); 
-
80:	content.setBackground(d); 
-
83:	AttachInfo_Accessor.setAttachInfo(content); 
-
91:	content.measure(w_spec, h_spec); 
-
94:	content.layout(0, 0, w, h); 
-
97:	AttachInfo_Accessor.dispatchOnPreDraw(content); 
-
111:	content.draw(canvas); 
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: setLayoutParams, setOnTouchListener, addView
75:	final FrameLayout layout = new FrameLayout(context); 
-
77:	layout.setLayoutParams(layoutParams); 
78:	layout.addView(textView); 
79:	layout.setOnTouchListener(this); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getMeasuredHeight, getMeasuredWidth, getVisibility, layout
400:	if (enableZoomControls && zoomControls.getVisibility() == View.VISIBLE) { 
401:	int zoomWidth = zoomControls.getMeasuredWidth(); 
402:	int zoomHeight = zoomControls.getMeasuredHeight(); 
403:	zoomControls.layout(parentRight - zoomWidth, parentBottom - zoomHeight, parentRight, parentBottom); 
Full Snippet Info
8
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: getParent, removeView
92:	ViewParent newEmptyViewParent = newEmptyView.getParent(); 
-
95:	((ViewGroup) newEmptyViewParent).removeView(newEmptyView); 
-
105:	.setEmptyViewInternal(newEmptyView); 
-
107:	this.mRefreshableView.setEmptyView(newEmptyView); 
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: setLayoutParams, addView
185:	RelativeLayout layout = new RelativeLayout(activity); 
186:	layout.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT, ListView.LayoutParams.WRAP_CONTENT)); 
-
196:	layout.addView(webView); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setBackgroundColor, addView
35:	FrameLayout layout = new FrameLayout(this); 
-
39:	layout.addView(b); 
40:	layout.setBackgroundColor(0xffffffff); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setLayoutDirection, addView, setAlignmentMode, setRowOrderPreserved, setUseDefaultMargins
49:	GridLayout layout = new GridLayout(context); 
50:	layout.setUseDefaultMargins(true); 
51:	layout.setAlignmentMode(ALIGN_BOUNDS); 
52:	layout.setRowOrderPreserved(false); 
53:	layout.setLayoutDirection(View.LAYOUT_DIRECTION_RTL); 
-
75:	layout.addView(c, new GridLayout.LayoutParams(row1, col1a)); 
-
81:	layout.addView(c, new GridLayout.LayoutParams(row2, col1b)); 
-
86:	layout.addView(c, new GridLayout.LayoutParams(row3, col1c)); 
-
92:	layout.addView(c, new GridLayout.LayoutParams(row3, col2)); 
-
97:	layout.addView(c, new GridLayout.LayoutParams(row4, col1c)); 
-
103:	layout.addView(c, new GridLayout.LayoutParams(row4, col2)); 
-
107:	layout.addView(c, new GridLayout.LayoutParams(row5, col3)); 
-
112:	layout.addView(c, new GridLayout.LayoutParams(row6, col4a)); 
-
117:	layout.addView(c, new GridLayout.LayoutParams(row7, col4b)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setLayoutDirection, addView, setAlignmentMode, setRowOrderPreserved, setUseDefaultMargins
49:	GridLayout layout = new GridLayout(context); 
50:	layout.setUseDefaultMargins(true); 
51:	layout.setAlignmentMode(ALIGN_BOUNDS); 
52:	layout.setRowOrderPreserved(false); 
53:	layout.setLayoutDirection(View.LAYOUT_DIRECTION_LTR); 
-
75:	layout.addView(c, new GridLayout.LayoutParams(row1, col1a)); 
-
81:	layout.addView(c, new GridLayout.LayoutParams(row2, col1b)); 
-
86:	layout.addView(c, new GridLayout.LayoutParams(row3, col1c)); 
-
92:	layout.addView(c, new GridLayout.LayoutParams(row3, col2)); 
-
97:	layout.addView(c, new GridLayout.LayoutParams(row4, col1c)); 
-
103:	layout.addView(c, new GridLayout.LayoutParams(row4, col2)); 
-
107:	layout.addView(c, new GridLayout.LayoutParams(row5, col3)); 
-
112:	layout.addView(c, new GridLayout.LayoutParams(row6, col4a)); 
-
117:	layout.addView(c, new GridLayout.LayoutParams(row7, col4b)); 
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: measure, setBackgroundDrawable, layout, draw, dispatchOnPreDraw
74:	FrameLayout content = new FrameLayout(context); 
-
78:	content.setBackgroundDrawable(d); 
-
81:	AttachInfo_Accessor.setAttachInfo(content); 
-
89:	content.measure(w_spec, h_spec); 
-
92:	content.layout(0, 0, w, h); 
-
95:	AttachInfo_Accessor.dispatchOnPreDraw(content); 
-
109:	content.draw(canvas); 
Full Snippet Info
8
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
58:	root = new RelativeLayout(this); 
59:	root.setLayoutParams(containerParams); 
-
63:	root.addView(mSurfaceView); 
-
73:	root.addView(stopButton); 
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
74:	FrameLayout root = new FrameLayout(getActivity()); 
-
79:	root.addView(tv, new FrameLayout.LayoutParams( 
-
85:	root.addView(lv, new FrameLayout.LayoutParams( 
-
90:	root.setLayoutParams(lp); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getParent, removeView
91:	ViewParent newEmptyViewParent = newEmptyView.getParent(); 
-
94:	((ViewGroup) newEmptyViewParent).removeView(newEmptyView); 
-
104:	.setEmptyViewInternal(newEmptyView); 
-
106:	this.mRefreshableView.setEmptyView(newEmptyView); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: addView
37:	final FrameLayout layout = new FrameLayout(this); 
38:	layout.addView(view, new FrameLayout.LayoutParams(800, 400, Gravity.CENTER)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: addView, setGravity
109:	RelativeLayout layout = new RelativeLayout ( this ); 
110:	layout.setGravity ( Gravity.CENTER ); 
-
116:	layout.addView ( mVideoView, new RelativeLayout.LayoutParams ( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT )); 
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: addView
33:	FrameLayout layout = new FrameLayout(this); 
-
44:	layout.addView(b); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getContext, getChildAt, getHeaderViewsCount, getFirstVisiblePosition
37:	View v = mListView.getChildAt(position + mListView.getHeaderViewsCount() 
38:	- mListView.getFirstVisiblePosition()); 
-
50:	ImageView iv = new ImageView(mListView.getContext()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getVerticalFadingEdgeLength, getChildAt, getChildCount, getMaxScrollAmount, getCount
44:	assertEquals("list item count", 5, mListView.getCount()); 
45:	assertEquals("list visible child count", 3, mListView.getChildCount()); 
46:	int firstTwoHeight = mListView.getChildAt(0).getHeight() + mListView.getChildAt(1).getHeight(); 
-
48:	firstTwoHeight <= mListView.getVerticalFadingEdgeLength()); 
-
50:	firstTwoHeight <= mListView.getMaxScrollAmount()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: addView
44:	FrameLayout content = new FrameLayout(this); 
-
73:	content.addView(mTextureView, new FrameLayout.LayoutParams(500, 400, Gravity.CENTER)); 
74:	content.addView(button, new FrameLayout.LayoutParams( 
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: 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: getChildAt, performItemClick, getAdapter
53:	long itemId = listView.getAdapter().getItemId(TESTED_CLICKED_INDEX); 
54:	View view = listView.getChildAt(TESTED_CLICKED_INDEX); 
-
57:	listView.performItemClick(view, TESTED_CLICKED_INDEX, itemId); 
Full Snippet Info
9
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: 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: clearDisappearingChildren, clearFocus, clearCache, clearFormData, clearHistory
41:	webView.clearCache(true); 
42:	webView.clearHistory(); 
43:	webView.clearView(); 
44:	webView.clearSslPreferences(); 
45:	webView.clearDisappearingChildren(); 
46:	webView.clearFocus(); 
47:	webView.clearFormData(); 
48:	webView.clearMatches(); 
Full Snippet Info
7
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: getChildAt, getFirstVisiblePosition
52:	editor.putInt("index", listView.getFirstVisiblePosition()); 
53:	editor.putInt("top", listView.getChildAt(0) == null ? 0 : listView.getChildAt(0).getTop()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: addView
41:	final FrameLayout layout = new FrameLayout(this); 
42:	layout.addView(view, new FrameLayout.LayoutParams(480, 800, Gravity.CENTER)); 
Full Snippet Info
8
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: 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: 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: 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
Related Android ViewGroup Questions & Answers:
Other Android ViewGroup Examples
64:	        // Dropped, reassign View to ViewGroup
65:	        View view = (View) event.getLocalState();
66:	        ViewGroup owner = (ViewGroup) view.getParent();
67:	        owner.removeView(view);
68:	        LinearLayout container = (LinearLayout) v;
-
64:	        // Dropped, reassign View to ViewGroup
65:	        View view = (View) event.getLocalState();
66:	        ViewGroup owner = (ViewGroup) view.getParent();
67:	        owner.removeView(view);
68:	        LinearLayout container = (LinearLayout) v;

Read More

10:	
11:		@Override
12:		public View onCreateView(LayoutInflater inflater, ViewGroup container,
13:				Bundle savedInstanceState) {
14:

Read More

10:	
11:		@Override
12:		public View onCreateView(LayoutInflater inflater, ViewGroup container,
13:				Bundle savedInstanceState) {
14:

Read More

10:	
11:		@Override
12:		public View onCreateView(LayoutInflater inflater, ViewGroup container,
13:				Bundle savedInstanceState) {
14:

Read More

1:	public View onCreateView(LayoutInflater inflater, ViewGroup container,
2:	        Bundle savedInstanceState) {
3:	    ...

Read More

19:	
20:	    // create a new ImageView for each item referenced by the Adapter
21:	    public View getView(int position, View convertView, ViewGroup parent) {
22:	        ImageView imageView;
23:	        if (convertView == null) {  // if it's not recycled, initialize some attributes

Read More

26:	
27:	        // Must add the progress bar to the root of the layout
28:	        ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
29:	        root.addView(progressBar);
30:	
-
26:	
27:	        // Must add the progress bar to the root of the layout
28:	        ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
29:	        root.addView(progressBar);
30:

Read More

See Code Examples for Android ViewGroup Methods: