Code example for HorizontalScrollView

Methods: addView

7
		layout.setOrientation(LinearLayout.HORIZONTAL);
		layout.addView(tv);
		layout.addView(bt);
		layout.addView(bt1);
 
		HorizontalScrollView horizontalScrollView = new HorizontalScrollView(
				context);
		horizontalScrollView.addView(layout);
 
		addView(horizontalScrollView);
	} 
 
	@Override 
	// 对每个子View进行measure():设置每子View的大小,即实际宽和高 
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// 通过init()方法,我们为该ViewGroup对象添加了三个视图 , Button、 ImageView、TextView 
		// widthMeasureSpec = 480; 
		int childCount = getChildCount();
		Log.i(TAG, "the size of this ViewGroup is ----> " + childCount);
 
Stop searching for code, let great code find you!  Add Codota to your java IDE