FileDocCategorySizeDatePackage
ScrollViewScenario.javaAPI DocAndroid 1.5 API8802Wed May 06 22:42:02 BST 2009com.android.frameworktest.util

ScrollViewScenario

public abstract class ScrollViewScenario extends android.app.Activity
Utility base class for creating scroll view scenarios, allowing you to add a series of different kinds of views arranged vertically, taking up a specified amount of the screen height.

Fields Summary
private android.widget.LinearLayout
mLinearLayout
Holds content of scroll view
private android.widget.ScrollView
mScrollView
The actual scroll view
Constructors Summary
Methods Summary
protected android.widget.ScrollViewcreateScrollView()
Hook for changing how scroll view's are created.

        return new ScrollView(this);
    
public TgetContentChildAt(int index)
Get the child contained within the vertical linear layout of the scroll view.

param
index The index within the linear layout.
return
the child within the vertical linear layout of the scroll view at the specified index.

        return (T) mLinearLayout.getChildAt(index);
    
public android.widget.LinearLayoutgetLinearLayout()

        return mLinearLayout;
    
public android.widget.ScrollViewgetScrollView()

        return mScrollView;
    
protected abstract voidinit(com.android.frameworktest.util.ScrollViewScenario$Params params)
Override this and initialized the views in the scroll view.

param
params Used to configure the contents of the scroll view.

protected voidonCreate(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) {
            final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.FILL_PARENT,
                    (int) (viewFactory.getHeightRatio() * screenHeight));
            mLinearLayout.addView(viewFactory.create(this), lp);
        }

        mScrollView = createScrollView();
        mScrollView.addView(mLinearLayout, new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));

        // no animation to speed up tests
        mScrollView.setSmoothScrollingEnabled(false);

        setContentView(mScrollView);