am 888ac28d: Fixes to GridLayout demos.
* commit '888ac28d79e6bcba43b200bc3d9ed971e0516c2b': Fixes to GridLayout demos.
This commit is contained in:
@@ -1605,14 +1605,21 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".view.GridLayout0" android:label="Views/Layouts/GridLayout/0. Simple Form (Java)">
|
<activity android:name=".view.GridLayout1" android:label="Views/Layouts/GridLayout/1. Simple Form">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".view.GridLayout1" android:label="Views/Layouts/GridLayout/1. Simple Form (XML)">
|
<activity android:name=".view.GridLayout2" android:label="Views/Layouts/GridLayout/2. Form (XML)">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".view.GridLayout3" android:label="Views/Layouts/GridLayout/3. Form (Java)">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
|||||||
63
samples/ApiDemos/res/layout-land/grid_layout_2.xml
Normal file
63
samples/ApiDemos/res/layout-land/grid_layout_2.xml
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2011 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<GridLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:useDefaultMargins="true"
|
||||||
|
android:alignmentMode="alignBounds"
|
||||||
|
android:rowOrderPreserved="false"
|
||||||
|
android:columnCount="4"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:text="Email setup"
|
||||||
|
android:textSize="32dip"
|
||||||
|
android:layout_columnSpan="4"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:text="You can configure email in a few simple steps:"
|
||||||
|
android:textSize="16dip"
|
||||||
|
android:layout_columnSpan="4"
|
||||||
|
android:layout_gravity="left"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:text="Email address:"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
/>
|
||||||
|
<EditText
|
||||||
|
android:ems="10"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:text="Password:"
|
||||||
|
android:layout_column="0"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
/>
|
||||||
|
<EditText
|
||||||
|
android:ems="8"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
android:text="Manual setup"
|
||||||
|
android:layout_row="5"
|
||||||
|
android:layout_column="3"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
android:text="Next"
|
||||||
|
android:layout_column="3"
|
||||||
|
android:layout_gravity="fill_horizontal"
|
||||||
|
/>
|
||||||
|
</GridLayout>
|
||||||
@@ -14,74 +14,33 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Demonstrates using GridLayout to build the "Simple Form" from the
|
||||||
|
LinearLayout and RelativeLayout demos.
|
||||||
|
-->
|
||||||
|
|
||||||
<GridLayout
|
<GridLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:background="@drawable/blue"
|
||||||
|
android:columnCount="4"
|
||||||
android:useDefaultMargins="true"
|
android:padding="10dip"
|
||||||
android:alignmentMode="alignBounds"
|
>
|
||||||
android:rowOrderPreserved="false"
|
|
||||||
|
|
||||||
android:columnCount="4"
|
|
||||||
>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:text="Email setup"
|
android:text="@string/grid_layout_1_instructions"
|
||||||
android:textSize="32dip"
|
/>
|
||||||
|
|
||||||
android:layout_columnSpan="4"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:text="You can configure email in just a few steps:"
|
|
||||||
android:textSize="16dip"
|
|
||||||
|
|
||||||
android:layout_columnSpan="4"
|
|
||||||
android:layout_gravity="left"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:text="Email address:"
|
|
||||||
|
|
||||||
android:layout_gravity="right"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:ems="10"
|
android:layout_column="0"
|
||||||
/>
|
android:layout_columnSpan="4"
|
||||||
|
android:layout_gravity="fill_horizontal"
|
||||||
<TextView
|
/>
|
||||||
android:text="Password:"
|
|
||||||
|
|
||||||
android:layout_column="0"
|
|
||||||
android:layout_gravity="right"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:ems="8"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_row="2"
|
|
||||||
android:layout_rowSpan="3"
|
|
||||||
android:layout_column="2"
|
|
||||||
android:layout_gravity="fill"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:text="Manual setup"
|
android:layout_column="2"
|
||||||
|
android:text="@string/grid_layout_1_cancel"
|
||||||
android:layout_row="5"
|
/>
|
||||||
android:layout_column="3"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:text="Next"
|
android:layout_marginLeft="10dip"
|
||||||
|
android:text="@string/grid_layout_1_ok"
|
||||||
android:layout_column="3"
|
/>
|
||||||
android:layout_gravity="fill_horizontal"
|
|
||||||
/>
|
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
|
|||||||
63
samples/ApiDemos/res/layout/grid_layout_2.xml
Normal file
63
samples/ApiDemos/res/layout/grid_layout_2.xml
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2011 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<GridLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:useDefaultMargins="true"
|
||||||
|
android:alignmentMode="alignBounds"
|
||||||
|
android:columnOrderPreserved="false"
|
||||||
|
android:columnCount="4"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:text="Email setup"
|
||||||
|
android:textSize="32dip"
|
||||||
|
android:layout_columnSpan="4"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:text="You can configure email in a few simple steps:"
|
||||||
|
android:textSize="16dip"
|
||||||
|
android:layout_columnSpan="4"
|
||||||
|
android:layout_gravity="left"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:text="Email address:"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
/>
|
||||||
|
<EditText
|
||||||
|
android:ems="10"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:text="Password:"
|
||||||
|
android:layout_column="0"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
/>
|
||||||
|
<EditText
|
||||||
|
android:ems="8"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
android:text="Manual setup"
|
||||||
|
android:layout_row="5"
|
||||||
|
android:layout_column="3"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
android:text="Next"
|
||||||
|
android:layout_column="3"
|
||||||
|
android:layout_gravity="fill_horizontal"
|
||||||
|
/>
|
||||||
|
</GridLayout>
|
||||||
@@ -1073,6 +1073,9 @@
|
|||||||
<string name="focus_5_button4">4</string>
|
<string name="focus_5_button4">4</string>
|
||||||
<string name="focus_5_button5">5</string>
|
<string name="focus_5_button5">5</string>
|
||||||
<string name="gallery_2_text">Testing</string>
|
<string name="gallery_2_text">Testing</string>
|
||||||
|
<string name="grid_layout_1_instructions">Type here:</string>
|
||||||
|
<string name="grid_layout_1_ok">Ok</string>
|
||||||
|
<string name="grid_layout_1_cancel">Cancel</string>
|
||||||
<string name="googlelogin_login">Login</string>
|
<string name="googlelogin_login">Login</string>
|
||||||
<string name="googlelogin_bad_login">Bad Login</string>
|
<string name="googlelogin_bad_login">Bad Login</string>
|
||||||
<string name="googlelogin_clear">Clear Credentials</string>
|
<string name="googlelogin_clear">Clear Credentials</string>
|
||||||
|
|||||||
@@ -16,13 +16,13 @@
|
|||||||
|
|
||||||
package com.example.android.apis.view;
|
package com.example.android.apis.view;
|
||||||
|
|
||||||
import com.example.android.apis.R;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import com.example.android.apis.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple form, showing use of the GridLayout API from XML.
|
* Demonstrates using GridLayout to build the same "Simple Form" as in the
|
||||||
|
* LinearLayout and RelativeLayout demos.
|
||||||
*/
|
*/
|
||||||
public class GridLayout1 extends Activity {
|
public class GridLayout1 extends Activity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2011 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.android.apis.view;
|
||||||
|
|
||||||
|
import com.example.android.apis.R;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A form, showing use of the GridLayout API from XML.
|
||||||
|
*/
|
||||||
|
public class GridLayout2 extends Activity {
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.grid_layout_2);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ package com.example.android.apis.view;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -25,81 +26,84 @@ import android.widget.*;
|
|||||||
|
|
||||||
import static android.text.InputType.*;
|
import static android.text.InputType.*;
|
||||||
import static android.widget.GridLayout.*;
|
import static android.widget.GridLayout.*;
|
||||||
|
import static android.widget.GridLayout.LayoutParams;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple form, showing use of the GridLayout API.
|
* A form, showing use of the GridLayout API. Here we demonstrate use of the row/column order
|
||||||
|
* preserved property which allows rows and or columns to pass over each other when needed.
|
||||||
|
* The two buttons in the bottom right corner need to be separated from the other UI elements.
|
||||||
|
* This can either be done by separating rows or separating columns - but we don't need
|
||||||
|
* to do both and may only have enough space to do one or the other.
|
||||||
*/
|
*/
|
||||||
public class GridLayout0 extends Activity {
|
public class GridLayout3 extends Activity {
|
||||||
|
|
||||||
public static View create(Context context) {
|
public static View create(Context context) {
|
||||||
GridLayout p = new GridLayout(context);
|
GridLayout p = new GridLayout(context);
|
||||||
p.setUseDefaultMargins(true);
|
p.setUseDefaultMargins(true);
|
||||||
p.setAlignmentMode(ALIGN_BOUNDS);
|
p.setAlignmentMode(ALIGN_BOUNDS);
|
||||||
p.setRowOrderPreserved(false);
|
Configuration configuration = context.getResources().getConfiguration();
|
||||||
|
if ((configuration.orientation == Configuration.ORIENTATION_PORTRAIT)) {
|
||||||
|
p.setColumnOrderPreserved(false);
|
||||||
|
} else {
|
||||||
|
p.setRowOrderPreserved(false);
|
||||||
|
}
|
||||||
|
|
||||||
Spec row1 = spec(0);
|
Spec titleRow = spec(0);
|
||||||
Spec row2 = spec(1);
|
Spec introRow = spec(1);
|
||||||
Spec row3 = spec(2, BASELINE);
|
Spec emailRow = spec(2, BASELINE);
|
||||||
Spec row4 = spec(3, BASELINE);
|
Spec passwordRow = spec(3, BASELINE);
|
||||||
Spec row5 = spec(2, 3, FILL); // allow the last two rows to overlap the middle two
|
Spec button1Row = spec(5);
|
||||||
Spec row6 = spec(5);
|
Spec button2Row = spec(6);
|
||||||
Spec row7 = spec(6);
|
|
||||||
|
|
||||||
Spec col1a = spec(0, 4, CENTER);
|
Spec centerInAllColumns = spec(0, 4, CENTER);
|
||||||
Spec col1b = spec(0, 4, LEFT);
|
Spec leftAlignInAllColumns = spec(0, 4, LEFT);
|
||||||
Spec col1c = spec(0, RIGHT);
|
Spec labelColumn = spec(0, RIGHT);
|
||||||
Spec col2 = spec(1, LEFT);
|
Spec fieldColumn = spec(1, LEFT);
|
||||||
Spec col3 = spec(2, FILL);
|
Spec defineLastColumn = spec(3);
|
||||||
Spec col4a = spec(3);
|
Spec fillLastColumn = spec(3, FILL);
|
||||||
Spec col4b = spec(3, FILL);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
TextView c = new TextView(context);
|
TextView c = new TextView(context);
|
||||||
c.setTextSize(32);
|
c.setTextSize(32);
|
||||||
c.setText("Email setup");
|
c.setText("Email setup");
|
||||||
p.addView(c, new LayoutParams(row1, col1a));
|
p.addView(c, new LayoutParams(titleRow, centerInAllColumns));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
TextView c = new TextView(context);
|
TextView c = new TextView(context);
|
||||||
c.setTextSize(16);
|
c.setTextSize(16);
|
||||||
c.setText("You can configure email in just a few steps:");
|
c.setText("You can configure email in a few simple steps:");
|
||||||
p.addView(c, new LayoutParams(row2, col1b));
|
p.addView(c, new LayoutParams(introRow, leftAlignInAllColumns));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
TextView c = new TextView(context);
|
TextView c = new TextView(context);
|
||||||
c.setText("Email address:");
|
c.setText("Email address:");
|
||||||
p.addView(c, new LayoutParams(row3, col1c));
|
p.addView(c, new LayoutParams(emailRow, labelColumn));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
EditText c = new EditText(context);
|
EditText c = new EditText(context);
|
||||||
c.setEms(10);
|
c.setEms(10);
|
||||||
c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
||||||
p.addView(c, new LayoutParams(row3, col2));
|
p.addView(c, new LayoutParams(emailRow, fieldColumn));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
TextView c = new TextView(context);
|
TextView c = new TextView(context);
|
||||||
c.setText("Password:");
|
c.setText("Password:");
|
||||||
p.addView(c, new LayoutParams(row4, col1c));
|
p.addView(c, new LayoutParams(passwordRow, labelColumn));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
TextView c = new EditText(context);
|
TextView c = new EditText(context);
|
||||||
c.setEms(8);
|
c.setEms(8);
|
||||||
c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD);
|
c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD);
|
||||||
p.addView(c, new LayoutParams(row4, col2));
|
p.addView(c, new LayoutParams(passwordRow, fieldColumn));
|
||||||
}
|
|
||||||
{
|
|
||||||
Space c = new Space(context);
|
|
||||||
p.addView(c, new LayoutParams(row5, col3));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Button c = new Button(context);
|
Button c = new Button(context);
|
||||||
c.setText("Manual setup");
|
c.setText("Manual setup");
|
||||||
p.addView(c, new LayoutParams(row6, col4a));
|
p.addView(c, new LayoutParams(button1Row, defineLastColumn));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Button c = new Button(context);
|
Button c = new Button(context);
|
||||||
c.setText("Next");
|
c.setText("Next");
|
||||||
p.addView(c, new LayoutParams(row7, col4b));
|
p.addView(c, new LayoutParams(button2Row, fillLastColumn));
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
Reference in New Issue
Block a user