diff options
Diffstat (limited to 'tests/GridLayoutTest')
-rw-r--r-- | tests/GridLayoutTest/res/drawable/btn_default.xml | 33 | ||||
-rw-r--r-- | tests/GridLayoutTest/res/drawable/btn_default_normal.9.png (renamed from tests/GridLayoutTest/res/drawable/my_btn_default_normal.9.png) | bin | 1269 -> 1269 bytes | |||
-rwxr-xr-x | tests/GridLayoutTest/res/drawable/my_btn_default_normal_disable.9.png | bin | 3601 -> 0 bytes | |||
-rwxr-xr-x | tests/GridLayoutTest/res/drawable/my_btn_default_normal_disable_focused.9.png | bin | 1781 -> 0 bytes | |||
-rwxr-xr-x | tests/GridLayoutTest/res/drawable/my_btn_default_pressed.9.png | bin | 1913 -> 0 bytes | |||
-rwxr-xr-x | tests/GridLayoutTest/res/drawable/my_btn_default_selected.9.png | bin | 1507 -> 0 bytes | |||
-rw-r--r-- | tests/GridLayoutTest/src/com/android/test/layout/LayoutInsetsTest.java | 59 |
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 Binary files differindex cd0b7d5..cd0b7d5 100644 --- a/tests/GridLayoutTest/res/drawable/my_btn_default_normal.9.png +++ b/tests/GridLayoutTest/res/drawable/btn_default_normal.9.png 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 Binary files differdeleted file mode 100755 index f4f01c7..0000000 --- a/tests/GridLayoutTest/res/drawable/my_btn_default_normal_disable.9.png +++ /dev/null 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 Binary files differdeleted file mode 100755 index 5376db2..0000000 --- a/tests/GridLayoutTest/res/drawable/my_btn_default_normal_disable_focused.9.png +++ /dev/null diff --git a/tests/GridLayoutTest/res/drawable/my_btn_default_pressed.9.png b/tests/GridLayoutTest/res/drawable/my_btn_default_pressed.9.png Binary files differdeleted file mode 100755 index 4312c27..0000000 --- a/tests/GridLayoutTest/res/drawable/my_btn_default_pressed.9.png +++ /dev/null diff --git a/tests/GridLayoutTest/res/drawable/my_btn_default_selected.9.png b/tests/GridLayoutTest/res/drawable/my_btn_default_selected.9.png Binary files differdeleted file mode 100755 index 06b7790..0000000 --- a/tests/GridLayoutTest/res/drawable/my_btn_default_selected.9.png +++ /dev/null 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; } |