Add API demo for new -wNNNdp and -hNNNdp configs.
Change-Id: I3c0e53f4007c5a486855346b2b7221ce4f2739c3
This commit is contained in:
@@ -1018,6 +1018,16 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".content.ResourcesWidthAndHeight"
|
||||
android:label="@string/activity_resources_width_and_height"
|
||||
android:enabled="@bool/atLeastIceCreamSandwich">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||
<category android:name="android.intent.category.EMBED" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".content.ReadAsset" android:label="@string/activity_read_asset">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
43
samples/ApiDemos/res/layout-h420dp/resources_height.xml
Normal file
43
samples/ApiDemos/res/layout-h420dp/resources_height.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<!-- Part of resources_width_and_height that varies based on height. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#8000ff00">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#80ff0000">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#8000ff00">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#80ff0000">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
63
samples/ApiDemos/res/layout-h670dp/resources_height.xml
Normal file
63
samples/ApiDemos/res/layout-h670dp/resources_height.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.
|
||||
-->
|
||||
|
||||
<!-- Part of resources_width_and_height that varies based on height. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#8000ff00">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#80ff0000">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#8000ff00">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#80ff0000">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#8000ff00">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#80ff0000">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#8000ff00">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#80ff0000">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
43
samples/ApiDemos/res/layout-w420dp/resources_width.xml
Normal file
43
samples/ApiDemos/res/layout-w420dp/resources_width.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<!-- Part of resources_width_and_height that varies based on width. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w420dp Width\n#1">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w420dp Width\n#2">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w420dp Width\n#3">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w420dp Width\n#4">
|
||||
</TextView>
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
63
samples/ApiDemos/res/layout-w720dp/resources_width.xml
Normal file
63
samples/ApiDemos/res/layout-w720dp/resources_width.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.
|
||||
-->
|
||||
|
||||
<!-- Part of resources_width_and_height that varies based on width. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w720dp Width\n#1">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w720dp Width\n#2">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w720dp Width\n#3">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w720dp Width\n#4">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w720dp Width\n#5">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w720dp Width\n#6">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w720dp Width\n#7">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="w720dp Width\n#8">
|
||||
</TextView>
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
33
samples/ApiDemos/res/layout/resources_height.xml
Normal file
33
samples/ApiDemos/res/layout/resources_height.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<!-- Part of resources_width_and_height that varies based on height. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#8000ff00">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1" android:padding="4dp"
|
||||
android:background="#80ff0000">
|
||||
<include layout="@layout/resources_width" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
33
samples/ApiDemos/res/layout/resources_width.xml
Normal file
33
samples/ApiDemos/res/layout/resources_width.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<!-- Part of resources_width_and_height that varies based on width. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="Default Width\n#1">
|
||||
</TextView>
|
||||
<TextView android:layout_width="0px" android:layout_height="match_parent"
|
||||
android:layout_weight="1" android:gravity="center_horizontal"
|
||||
android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
|
||||
android:background="#800000ff" android:text="Default Width\n#2">
|
||||
</TextView>
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
35
samples/ApiDemos/res/layout/resources_width_and_height.xml
Normal file
35
samples/ApiDemos/res/layout/resources_width_and_height.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<!-- Demonstrates using -wNNNdp and -hNNNdp resource configs. -->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||
android:layout_weight="0" android:gravity="center_horizontal"
|
||||
android:paddingTop="8dp" android:paddingBottom="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/resources_width_and_height_description"/>
|
||||
|
||||
<FrameLayout android:layout_width="match_parent" android:layout_height="0px"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:drawable/gallery_thumb">
|
||||
<include layout="@layout/resources_height" />
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
20
samples/ApiDemos/res/values-v13/bools.xml
Normal file
20
samples/ApiDemos/res/values-v13/bools.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- True if running under Ice Cream Sandwich or later. -->
|
||||
<bool name="atLeastIceCreamSandwich">true</bool>
|
||||
</resources>
|
||||
@@ -19,4 +19,8 @@
|
||||
API level. The default value is false; an alternative value
|
||||
for Honeycomb is true. -->
|
||||
<bool name="atLeastHoneycomb">false</bool>
|
||||
<!-- This resource is true if running under at least Ice Cream Sandwich's
|
||||
API level. The default value is false; an alternative value
|
||||
for Ice Cream Sandwich is true. -->
|
||||
<bool name="atLeastIceCreamSandwich">false</bool>
|
||||
</resources>
|
||||
|
||||
@@ -350,13 +350,17 @@
|
||||
<string name="styled_text">Plain, <b>bold</b>, <i>italic</i>, <b><i>bold-italic</i></b></string>
|
||||
<string name="styled_text_prog">Assigned programmatically:</string>
|
||||
|
||||
<string name="activity_resources_width_and_height">Content/Resources/Width and Height</string>
|
||||
<string name="resources_width_and_height_description">The layouts below use -wNNNdp and
|
||||
-hNNNdp to select between different versions based on the size of the screen.</string>
|
||||
|
||||
<string name="activity_read_asset">Content/Assets/Read Asset</string>
|
||||
|
||||
<string name="activity_themes">Content/Resources/Themes</string>
|
||||
<string name="activity_resources">Content/Resources/Resources</string>
|
||||
|
||||
<string name="activity_pick_contact">Content/Provider/Pick Contact</string>
|
||||
<string name="pick_contact_msg">Invoke Contacts to pick varius kinds of
|
||||
<string name="pick_contact_msg">Invoke Contacts to pick various kinds of
|
||||
contact data. None of these require that the caller hold the
|
||||
READ_CONTACTS permission.</string>
|
||||
<string name="pick_contact">Pick a Contact</string>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.content;
|
||||
|
||||
import com.example.android.apis.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class ResourcesWidthAndHeight extends Activity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// This layout uses different configurations to adjust
|
||||
// what is shown based on the current screen width and height.
|
||||
setContentView(R.layout.resources_width_and_height);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user