summaryrefslogtreecommitdiffstats
path: root/tests/GridLayoutTest
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
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')
-rw-r--r--tests/GridLayoutTest/res/drawable/btn_default.xml33
-rw-r--r--tests/GridLayoutTest/res/drawable/btn_default_normal.9.png (renamed from tests/GridLayoutTest/res/drawable/my_btn_default_normal.9.png)bin1269 -> 1269 bytes
-rwxr-xr-xtests/GridLayoutTest/res/drawable/my_btn_default_normal_disable.9.pngbin3601 -> 0 bytes
-rwxr-xr-xtests/GridLayoutTest/res/drawable/my_btn_default_normal_disable_focused.9.pngbin1781 -> 0 bytes
-rwxr-xr-xtests/GridLayoutTest/res/drawable/my_btn_default_pressed.9.pngbin1913 -> 0 bytes
-rwxr-xr-xtests/GridLayoutTest/res/drawable/my_btn_default_selected.9.pngbin1507 -> 0 bytes
-rw-r--r--tests/GridLayoutTest/src/com/android/test/layout/LayoutInsetsTest.java59
7 files changed, 31 insertions, 61 deletions
diff --git a/tests/GridLayoutTest/res/drawable/btn_default.xml b/tests/GridLayoutTest/res/drawable/btn_default.xml
deleted file mode 100644
index c6cfda0..0000000
--- a/tests/GridLayoutTest/res/drawable/btn_default.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_window_focused="false" android:state_enabled="true"
- android:drawable="@drawable/my_btn_default_normal" />
- <item android:state_window_focused="false" android:state_enabled="false"
- android:drawable="@drawable/my_btn_default_normal" />
- <item android:state_pressed="true"
- android:drawable="@drawable/my_btn_default_pressed" />
- <item android:state_focused="true" android:state_enabled="true"
- android:drawable="@drawable/my_btn_default_selected" />
- <item android:state_enabled="true"
- android:drawable="@drawable/my_btn_default_normal" />
- <item android:state_focused="true"
- android:drawable="@drawable/my_btn_default_normal_disable_focused" />
- <item
- android:drawable="@drawable/my_btn_default_normal_disable" />
-</selector>
diff --git a/tests/GridLayoutTest/res/drawable/my_btn_default_normal.9.png b/tests/GridLayoutTest/res/drawable/btn_default_normal.9.png
index cd0b7d5..cd0b7d5 100644
--- a/tests/GridLayoutTest/res/drawable/my_btn_default_normal.9.png
+++ b/tests/GridLayoutTest/res/drawable/btn_default_normal.9.png
Binary files differ
diff --git a/tests/GridLayoutTest/res/drawable/my_btn_default_normal_disable.9.png b/tests/GridLayoutTest/res/drawable/my_btn_default_normal_disable.9.png
deleted file mode 100755
index f4f01c7..0000000
--- a/tests/GridLayoutTest/res/drawable/my_btn_default_normal_disable.9.png
+++ /dev/null
Binary files differ
diff --git a/tests/GridLayoutTest/res/drawable/my_btn_default_normal_disable_focused.9.png b/tests/GridLayoutTest/res/drawable/my_btn_default_normal_disable_focused.9.png
deleted file mode 100755
index 5376db2..0000000
--- a/tests/GridLayoutTest/res/drawable/my_btn_default_normal_disable_focused.9.png
+++ /dev/null
Binary files differ
diff --git a/tests/GridLayoutTest/res/drawable/my_btn_default_pressed.9.png b/tests/GridLayoutTest/res/drawable/my_btn_default_pressed.9.png
deleted file mode 100755
index 4312c27..0000000
--- a/tests/GridLayoutTest/res/drawable/my_btn_default_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/tests/GridLayoutTest/res/drawable/my_btn_default_selected.9.png b/tests/GridLayoutTest/res/drawable/my_btn_default_selected.9.png
deleted file mode 100755
index 06b7790..0000000
--- a/tests/GridLayoutTest/res/drawable/my_btn_default_selected.9.png
+++ /dev/null
Binary files differ
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;
}