summaryrefslogtreecommitdiffstats
path: root/tests/GridLayoutTest/src
diff options
context:
space:
mode:
authorPhilip Milne <pmilne@google.com>2012-04-24 22:12:36 -0700
committerPhilip Milne <pmilne@google.com>2012-04-27 16:46:57 -0700
commit7a23b49a8ceb07d3fa12c45fd42cd16131fd746a (patch)
tree3d0ba87bbc84830260a01a34d0abb5c13d6dd4d3 /tests/GridLayoutTest/src
parentc887843b19c5a31bcd14e0b29b035d2a6e1e6149 (diff)
downloadframeworks_base-7a23b49a8ceb07d3fa12c45fd42cd16131fd746a.zip
frameworks_base-7a23b49a8ceb07d3fa12c45fd42cd16131fd746a.tar.gz
frameworks_base-7a23b49a8ceb07d3fa12c45fd42cd16131fd746a.tar.bz2
Fixes for optical bounds feature.
1. Make the feature opt-in (ViewGroup::layoutMode defaults to CLIP_BOUNDS) without inheritance. 2. Rename COMPONENT_BOUNDS to CLIP_BOUNDS. 3. Rename LAYOUT_BOUNDS to OPTICAL_BOUNDS. 4. Complete GridLayout implementation. 5. Change the default_gap between components to 8dp, to align with the Style Guide. Change-Id: I8d40dfc5f4ca469f6424eb3ff60d07bec56e3a9f
Diffstat (limited to 'tests/GridLayoutTest/src')
-rw-r--r--tests/GridLayoutTest/src/com/android/test/layout/LayoutInsetsTest.java59
1 files changed, 31 insertions, 28 deletions
diff --git a/tests/GridLayoutTest/src/com/android/test/layout/LayoutInsetsTest.java b/tests/GridLayoutTest/src/com/android/test/layout/LayoutInsetsTest.java
index e9e1ae7..103de2f 100644
--- a/tests/GridLayoutTest/src/com/android/test/layout/LayoutInsetsTest.java
+++ b/tests/GridLayoutTest/src/com/android/test/layout/LayoutInsetsTest.java
@@ -4,47 +4,50 @@ import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
+import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.GridLayout;
import android.widget.TextView;
-import static android.widget.GridLayout.*;
+import static android.widget.GridLayout.ALIGN_BOUNDS;
+import static android.widget.GridLayout.LayoutParams;
+import static android.widget.GridLayout.OPTICAL_BOUNDS;
public class LayoutInsetsTest extends Activity {
+ static int[] GRAVITIES = {Gravity.LEFT, Gravity.LEFT, Gravity.CENTER_HORIZONTAL, Gravity.RIGHT, Gravity.RIGHT};
+
public static View create(Context context) {
+ final int N = GRAVITIES.length;
+
GridLayout p = new GridLayout(context);
p.setUseDefaultMargins(true);
- p.setAlignmentMode(ALIGN_BOUNDS);
- p.setOrientation(VERTICAL);
-
- {
- TextView c = new TextView(context);
- c.setTextSize(32);
- c.setText("Email setup");
- p.addView(c);
- }
- {
- Button c = new Button(context);
- c.setBackgroundResource(R.drawable.btn_default);
- c.setText("Test");
- p.addView(c);
- }
+ //p.setAlignmentMode(ALIGN_BOUNDS);
+ p.setLayoutMode(OPTICAL_BOUNDS);
+
+ p.setColumnCount(N);
+
+ for (int i = 0; i < 2*N; i++) {
+ View c;
+ if (i % 2 == 0) {
+ TextView tv = new TextView(context);
+ tv.setTextSize(32);
+ tv.setText("A");
+ c = tv;
+ } else {
+ Button b = new Button(context);
+ b.setBackgroundResource(R.drawable.btn_default_normal);
+ b.setText("B");
+ c = b;
+ }
+
+ LayoutParams lp = new LayoutParams();
+ lp.setGravity(GRAVITIES[(i % N)]);
+ p.addView(c, lp);
- {
- Button c = new Button(context);
- c.setBackgroundResource(R.drawable.btn_default);
- c.setText("Manual setup");
- p.addView(c);
- c.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- Button b = (Button) v;
- b.setEnabled(false);
- }
- });
}
+
return p;
}