Merge "Sample for percent support library." into lmp-mr1-ub-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ab748c0115
@@ -113,7 +113,8 @@ ANDROID_SUPPORT_LIBRARIES := \
|
|||||||
android-support-v17-leanback \
|
android-support-v17-leanback \
|
||||||
android-support-multidex \
|
android-support-multidex \
|
||||||
android-support-multidex-instrumentation \
|
android-support-multidex-instrumentation \
|
||||||
android-support-design
|
android-support-design \
|
||||||
|
android-support-percent
|
||||||
|
|
||||||
$(foreach lib, $(ANDROID_SUPPORT_LIBRARIES), $(eval $(call _package_sdk_library,$(lib))))
|
$(foreach lib, $(ANDROID_SUPPORT_LIBRARIES), $(eval $(call _package_sdk_library,$(lib))))
|
||||||
|
|
||||||
|
|||||||
@@ -498,6 +498,11 @@ frameworks/support/design/res
|
|||||||
frameworks/support/design/src/.readme extras/android/support/design/src/.readme
|
frameworks/support/design/src/.readme extras/android/support/design/src/.readme
|
||||||
${OUT_DIR}/target/common/obj/PACKAGING/android-support-design_intermediates/android-support-design.jar extras/android/support/design/libs/android-support-design.jar
|
${OUT_DIR}/target/common/obj/PACKAGING/android-support-design_intermediates/android-support-design.jar extras/android/support/design/libs/android-support-design.jar
|
||||||
|
|
||||||
|
frameworks/support/percent/AndroidManifest.xml extras/android/support/percent/AndroidManifest.xml
|
||||||
|
frameworks/support/percent/res extras/android/support/percent/res
|
||||||
|
frameworks/support/percent/src/.readme extras/android/support/percent/src/.readme
|
||||||
|
${OUT_DIR}/target/common/obj/PACKAGING/android-support-percent_intermediates/android-support-percent.jar extras/android/support/percent/libs/android-support-percent.jar
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Tests Component
|
# Tests Component
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|||||||
35
samples/SupportPercentDemos/Android.mk
Normal file
35
samples/SupportPercentDemos/Android.mk
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Copyright (C) 2015 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.
|
||||||
|
|
||||||
|
LOCAL_PATH:= $(call my-dir)
|
||||||
|
|
||||||
|
# Build the samples.
|
||||||
|
# We need to add some special AAPT flags to generate R classes
|
||||||
|
# for resources that are included from the libraries.
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
LOCAL_PACKAGE_NAME := SupportPercentDemos
|
||||||
|
LOCAL_MODULE_TAGS := samples
|
||||||
|
LOCAL_SDK_VERSION := current
|
||||||
|
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||||
|
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||||
|
android-support-percent \
|
||||||
|
android-support-v4 \
|
||||||
|
android-support-v13
|
||||||
|
LOCAL_RESOURCE_DIR = \
|
||||||
|
$(LOCAL_PATH)/res \
|
||||||
|
frameworks/support/percent/res
|
||||||
|
LOCAL_AAPT_FLAGS := \
|
||||||
|
--auto-add-overlay \
|
||||||
|
--extra-packages android.support.percent
|
||||||
|
include $(BUILD_PACKAGE)
|
||||||
40
samples/SupportPercentDemos/AndroidManifest.xml
Normal file
40
samples/SupportPercentDemos/AndroidManifest.xml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2015 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Declare the contents of this Android application. The namespace
|
||||||
|
attribute brings in the Android platform namespace, and the package
|
||||||
|
supplies a unique name for the application. When writing your
|
||||||
|
own application, the package name must be changed from "com.example.*"
|
||||||
|
to come from a domain that you own or have control over. -->
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.example.android.support.percent">
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="21" />
|
||||||
|
|
||||||
|
<application android:label="@string/activity_sample_code"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:icon="@drawable/app_sample_code">
|
||||||
|
|
||||||
|
<activity android:name="SupportPercentDemos">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
BIN
samples/SupportPercentDemos/res/drawable-hdpi/app_sample_code.png
Executable file
BIN
samples/SupportPercentDemos/res/drawable-hdpi/app_sample_code.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
38
samples/SupportPercentDemos/res/layout/demo_1.xml
Normal file
38
samples/SupportPercentDemos/res/layout/demo_1.xml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2015 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.
|
||||||
|
-->
|
||||||
|
<android.support.percent.PercentFrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
>
|
||||||
|
<View
|
||||||
|
app:layout_widthPercent="50%"
|
||||||
|
app:layout_heightPercent="50%"
|
||||||
|
app:layout_marginTopPercent="25%"
|
||||||
|
app:layout_marginLeftPercent="25%"
|
||||||
|
android:background="#FF0000"
|
||||||
|
/>
|
||||||
|
<View
|
||||||
|
android:layout_gravity="bottom|right"
|
||||||
|
app:layout_widthPercent="33.33%"
|
||||||
|
app:layout_heightPercent="33.33%"
|
||||||
|
app:layout_marginRightPercent="33.33%"
|
||||||
|
app:layout_marginBottomPercent="33.33%"
|
||||||
|
android:background="#0000FF"
|
||||||
|
/>
|
||||||
|
</android.support.percent.PercentFrameLayout>
|
||||||
38
samples/SupportPercentDemos/res/layout/demo_2.xml
Normal file
38
samples/SupportPercentDemos/res/layout/demo_2.xml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2015 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.
|
||||||
|
-->
|
||||||
|
<android.support.percent.PercentRelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
>
|
||||||
|
<View
|
||||||
|
android:id="@+id/left"
|
||||||
|
app:layout_widthPercent="25%"
|
||||||
|
app:layout_heightPercent="50%"
|
||||||
|
app:layout_marginLeftPercent="25%"
|
||||||
|
app:layout_marginTopPercent="25%"
|
||||||
|
android:background="#FF0000"
|
||||||
|
/>
|
||||||
|
<View
|
||||||
|
app:layout_widthPercent="25%"
|
||||||
|
app:layout_heightPercent="50%"
|
||||||
|
app:layout_marginTopPercent="25%"
|
||||||
|
android:layout_toRightOf="@id/left"
|
||||||
|
android:background="#0000FF"
|
||||||
|
/>
|
||||||
|
</android.support.percent.PercentRelativeLayout>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2015 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.
|
||||||
|
-->
|
||||||
|
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/pager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
/>
|
||||||
19
samples/SupportPercentDemos/res/values/strings.xml
Normal file
19
samples/SupportPercentDemos/res/values/strings.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2015 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>
|
||||||
|
<string name="activity_sample_code">Support Percent Demos</string>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 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.support.percent;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Fragment;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.app.FragmentManager;
|
||||||
|
import android.support.v13.app.FragmentStatePagerAdapter;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
public class SupportPercentDemos extends Activity {
|
||||||
|
private static final String LAYOUT_RESOURCE_ID = "layout_resource_id";
|
||||||
|
|
||||||
|
private ViewPager mPager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.support_percent_demos);
|
||||||
|
mPager = (ViewPager) findViewById(R.id.pager);
|
||||||
|
mPager.setAdapter(new Adapter(getFragmentManager()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Adapter extends FragmentStatePagerAdapter {
|
||||||
|
public Adapter(FragmentManager fm) {
|
||||||
|
super(fm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int position) {
|
||||||
|
PercentFragment fragment = new PercentFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
switch (position) {
|
||||||
|
case 0:
|
||||||
|
args.putInt(LAYOUT_RESOURCE_ID, R.layout.demo_1);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
args.putInt(LAYOUT_RESOURCE_ID, R.layout.demo_2);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PercentFragment extends Fragment {
|
||||||
|
public PercentFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
Bundle args = getArguments();
|
||||||
|
int layout = args.getInt(LAYOUT_RESOURCE_ID);
|
||||||
|
return inflater.inflate(layout, container, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user