Methods Summary |
---|
protected android.widget.ScrollView | createScrollView()Hook for changing how scroll view's are created.
return new ScrollView(this);
|
public T | getContentChildAt(int index)Get the child contained within the vertical linear layout of the
scroll view.
return (T) mLinearLayout.getChildAt(index);
|
public android.widget.LinearLayout | getLinearLayout()
return mLinearLayout;
|
public android.widget.ScrollView | getScrollView()
return mScrollView;
|
protected abstract void | init(android.util.ScrollViewScenario$Params params)Override this and initialized the views in the scroll view.
|
protected void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
// for test stability, turn off title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
int screenHeight = getWindowManager().getDefaultDisplay().getHeight()
- 25;
mLinearLayout = new LinearLayout(this);
mLinearLayout.setOrientation(LinearLayout.VERTICAL);
// initialize params
final Params params = new Params();
init(params);
// create views specified by params
for (ViewFactory viewFactory : params.mViewFactories) {
int height = ViewGroup.LayoutParams.WRAP_CONTENT;
if (viewFactory.getHeightRatio() >= 0) {
height = (int) (viewFactory.getHeightRatio() * screenHeight);
}
final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, height);
mLinearLayout.addView(viewFactory.create(this), lp);
}
mScrollView = createScrollView();
mScrollView.setPadding(0, params.mTopPadding, 0, params.mBottomPadding);
mScrollView.addView(mLinearLayout, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
// no animation to speed up tests
mScrollView.setSmoothScrollingEnabled(false);
setContentView(mScrollView);
|