summaryrefslogtreecommitdiffstats
path: root/core/tests/coretests/src/android/util/ScrollViewScenario.java
diff options
context:
space:
mode:
authorMattias Petersson <mattias.petersson@sonyericsson.com>2011-04-07 15:46:56 +0200
committerJohan Redestig <johan.redestig@sonyericsson.com>2011-04-07 15:46:56 +0200
commit5435a06010fb50dd8b495df6b7f21f15d82a2c0a (patch)
treef6835caa541856dd9f6873a13d4d730412dbd9c8 /core/tests/coretests/src/android/util/ScrollViewScenario.java
parent9907d161584415c81de1099678f160da172fd1a6 (diff)
downloadframeworks_base-5435a06010fb50dd8b495df6b7f21f15d82a2c0a.zip
frameworks_base-5435a06010fb50dd8b495df6b7f21f15d82a2c0a.tar.gz
frameworks_base-5435a06010fb50dd8b495df6b7f21f15d82a2c0a.tar.bz2
Scolling using arrow keys with padding
It was impossible to reach the end of a large test when scrolling down using the arrowkeys when the ScrollView had padding. A common example of this would be an AlertDialog with a text that is too long to fit on the screen. Change-Id: I55464290a0cdeabde83ccccc76fe8d015ae57a8d
Diffstat (limited to 'core/tests/coretests/src/android/util/ScrollViewScenario.java')
-rw-r--r--core/tests/coretests/src/android/util/ScrollViewScenario.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/core/tests/coretests/src/android/util/ScrollViewScenario.java b/core/tests/coretests/src/android/util/ScrollViewScenario.java
index 83afe06..db3d9d0 100644
--- a/core/tests/coretests/src/android/util/ScrollViewScenario.java
+++ b/core/tests/coretests/src/android/util/ScrollViewScenario.java
@@ -61,6 +61,7 @@ public abstract class ScrollViewScenario extends Activity {
/**
* Partially implement ViewFactory given a height ratio.
+ * A negative height ratio means that WRAP_CONTENT will be used as height
*/
private static abstract class ViewFactoryBase implements ViewFactory {
@@ -87,6 +88,9 @@ public abstract class ScrollViewScenario extends Activity {
List<ViewFactory> mViewFactories = Lists.newArrayList();
+ int mTopPadding = 0;
+ int mBottomPadding = 0;
+
/**
* Add a text view.
* @param text The text of the text view.
@@ -186,6 +190,13 @@ public abstract class ScrollViewScenario extends Activity {
});
return this;
}
+
+ public Params addPaddingToScrollView(int topPadding, int bottomPadding) {
+ mTopPadding = topPadding;
+ mBottomPadding = bottomPadding;
+
+ return this;
+ }
}
/**
@@ -239,13 +250,17 @@ public abstract class ScrollViewScenario extends Activity {
// 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,
- (int) (viewFactory.getHeightRatio() * screenHeight));
+ 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));