summaryrefslogtreecommitdiffstats
path: root/samples/SupportDesignDemos
diff options
context:
space:
mode:
Diffstat (limited to 'samples/SupportDesignDemos')
-rw-r--r--samples/SupportDesignDemos/Android.mk1
-rw-r--r--samples/SupportDesignDemos/AndroidManifest.xml27
-rw-r--r--samples/SupportDesignDemos/proguard.flags7
-rw-r--r--samples/SupportDesignDemos/res/layout/action_layout.xml23
-rw-r--r--samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_scroll_with_swiperefresh.xml48
-rw-r--r--samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_scroll_snap.xml49
-rw-r--r--samples/SupportDesignDemos/res/layout/design_bottom_sheet.xml72
-rw-r--r--samples/SupportDesignDemos/res/layout/design_tabs.xml41
-rw-r--r--samples/SupportDesignDemos/res/layout/design_tabs_viewpager.xml13
-rw-r--r--samples/SupportDesignDemos/res/layout/design_text_input.xml40
-rw-r--r--samples/SupportDesignDemos/res/menu/navigation.xml6
-rw-r--r--samples/SupportDesignDemos/res/values-w540dp/dimens.xml19
-rw-r--r--samples/SupportDesignDemos/res/values/dimens.xml19
-rw-r--r--samples/SupportDesignDemos/res/values/strings.xml6
-rw-r--r--samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenScrollWithSwipeRefresh.java27
-rw-r--r--samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsScrollSnap.java27
-rw-r--r--samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetUsage.java54
-rw-r--r--samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java69
18 files changed, 461 insertions, 87 deletions
diff --git a/samples/SupportDesignDemos/Android.mk b/samples/SupportDesignDemos/Android.mk
index f70b6e138..96068ee6f 100644
--- a/samples/SupportDesignDemos/Android.mk
+++ b/samples/SupportDesignDemos/Android.mk
@@ -37,4 +37,5 @@ LOCAL_AAPT_FLAGS := \
--extra-packages android.support.v7.appcompat \
--extra-packages android.support.v7.recyclerview \
--extra-packages android.support.design
+LOCAL_PROGUARD_FLAG_FILES := proguard.flags
include $(BUILD_PACKAGE)
diff --git a/samples/SupportDesignDemos/AndroidManifest.xml b/samples/SupportDesignDemos/AndroidManifest.xml
index a837458da..3a4dbdf04 100644
--- a/samples/SupportDesignDemos/AndroidManifest.xml
+++ b/samples/SupportDesignDemos/AndroidManifest.xml
@@ -109,6 +109,15 @@
</intent-filter>
</activity>
+ <activity android:name=".widget.AppBarLayoutToolbarScrollTabsScrollSnap"
+ android:label="@string/design_appbar_toolbar_scroll_tabs_scroll_snap"
+ android:theme="@style/Theme.Design">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.support.design.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
<activity android:name=".widget.AppBarLayoutToolbarScrollTabsPin"
android:label="@string/design_appbar_toolbar_scroll_tabs_pin"
android:theme="@style/Theme.Design">
@@ -154,6 +163,15 @@
</intent-filter>
</activity>
+ <activity android:name=".widget.AppBarLayoutToolbarCollapseThenScrollWithSwipeRefresh"
+ android:label="@string/design_appbar_collapsing_toolbar_scroll_with_swiperefresh"
+ android:theme="@style/Theme.Design">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.support.design.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
<activity android:name=".widget.AppBarLayoutToolbarCollapseWithImage"
android:label="@string/design_appbar_collapsing_toolbar_with_image"
android:theme="@style/Theme.Design">
@@ -181,5 +199,14 @@
</intent-filter>
</activity>
+ <activity android:name=".widget.BottomSheetUsage"
+ android:label="@string/design_bottomsheet"
+ android:theme="@style/Theme.Design">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.support.design.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
</application>
</manifest>
diff --git a/samples/SupportDesignDemos/proguard.flags b/samples/SupportDesignDemos/proguard.flags
new file mode 100644
index 000000000..9ebd7374d
--- /dev/null
+++ b/samples/SupportDesignDemos/proguard.flags
@@ -0,0 +1,7 @@
+-keep public class * extends android.support.design.widget.CoordinatorLayout$Behavior {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keep public class * extends android.support.v7.widget.LinearLayoutManager {
+ public <init>(android.content.Context, android.util.AttributeSet, int, int);
+}
diff --git a/samples/SupportDesignDemos/res/layout/action_layout.xml b/samples/SupportDesignDemos/res/layout/action_layout.xml
new file mode 100644
index 000000000..a266d5104
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/action_layout.xml
@@ -0,0 +1,23 @@
+<?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.v7.widget.SwitchCompat
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/toggle"
+ android:orientation="vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:gravity="center_vertical"/>
diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_scroll_with_swiperefresh.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_scroll_with_swiperefresh.xml
new file mode 100644
index 000000000..d0572afac
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_scroll_with_swiperefresh.xml
@@ -0,0 +1,48 @@
+<?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.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/col"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <android.support.design.widget.AppBarLayout
+ android:id="@+id/app_bar"
+ android:layout_height="192dp"
+ android:layout_width="match_parent"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+ <android.support.design.widget.CollapsingToolbarLayout
+ android:id="@+id/collapsing_app_bar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_height="?attr/actionBarSize"
+ android:layout_width="match_parent"
+ app:layout_collapseMode="pin"/>
+
+ </android.support.design.widget.CollapsingToolbarLayout>
+
+ </android.support.design.widget.AppBarLayout>
+
+ <include layout="@layout/include_appbar_recyclerview_swiperefresh"/>
+
+</android.support.design.widget.CoordinatorLayout>
diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_scroll_snap.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_scroll_snap.xml
new file mode 100644
index 000000000..b559ca370
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_scroll_snap.xml
@@ -0,0 +1,49 @@
+<?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.design.widget.CoordinatorLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/col"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <android.support.design.widget.AppBarLayout
+ android:id="@+id/app_bar"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_height="?attr/actionBarSize"
+ android:layout_width="match_parent"
+ app:layout_scrollFlags="scroll|enterAlways|snap"/>
+
+ <android.support.design.widget.TabLayout
+ android:id="@+id/tabs"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:layout_scrollFlags="scroll|enterAlways|snap"
+ app:tabMode="scrollable"/>
+
+ </android.support.design.widget.AppBarLayout>
+
+ <include layout="@layout/include_appbar_scrollview"/>
+
+</android.support.design.widget.CoordinatorLayout>
+
diff --git a/samples/SupportDesignDemos/res/layout/design_bottom_sheet.xml b/samples/SupportDesignDemos/res/layout/design_bottom_sheet.xml
new file mode 100644
index 000000000..56197eaec
--- /dev/null
+++ b/samples/SupportDesignDemos/res/layout/design_bottom_sheet.xml
@@ -0,0 +1,72 @@
+<?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.design.widget.CoordinatorLayout
+ android:id="@+id/coordinator"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res/com.example.android.support.design"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <!--
+ This is the bottom sheet. You can use any View as a bottom sheet by marking it with
+ app:layout_behavior as BottomSheetBehavior.
+ -->
+ <LinearLayout
+ android:id="@+id/bottom_sheet"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="@dimen/bottom_sheet_horizontal_margin"
+ android:layout_marginRight="@dimen/bottom_sheet_horizontal_margin"
+ android:background="?android:attr/windowBackground"
+ android:elevation="16dp"
+ android:minHeight="128dp"
+ android:orientation="vertical"
+ app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
+ app:behavior_peekHeight="128dp">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/bottom_sheet"
+ android:paddingTop="8dp"
+ android:paddingLeft="16dp"
+ android:paddingRight="16dp"
+ android:paddingBottom="8dp"
+ style="@style/TextAppearance.AppCompat.Title"/>
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="@android:color/darker_gray"/>
+
+ <android.support.v4.widget.NestedScrollView
+ android:id="@+id/scroll"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <TextView
+ android:id="@+id/dialogue"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ style="@style/TextAppearance.AppCompat.Body1"/>
+
+ </android.support.v4.widget.NestedScrollView>
+
+ </LinearLayout>
+
+</android.support.design.widget.CoordinatorLayout> \ No newline at end of file
diff --git a/samples/SupportDesignDemos/res/layout/design_tabs.xml b/samples/SupportDesignDemos/res/layout/design_tabs.xml
deleted file mode 100644
index b52d80833..000000000
--- a/samples/SupportDesignDemos/res/layout/design_tabs.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?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.
--->
-
-<LinearLayout 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"
- android:orientation="vertical">
-
- <android.support.v7.widget.Toolbar
- android:id="@+id/toolbar"
- android:layout_height="?attr/actionBarSize"
- android:layout_width="match_parent"
- android:background="?attr/colorPrimary"
- android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
- app:contentInsetStart="72dp"
- app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
-
- <android.support.design.widget.TabLayout
- android:id="@+id/tabs"
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:background="?attr/colorPrimary"
- android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
- app:tabContentStart="72dp"/>
-
-</LinearLayout>
diff --git a/samples/SupportDesignDemos/res/layout/design_tabs_viewpager.xml b/samples/SupportDesignDemos/res/layout/design_tabs_viewpager.xml
index b249155ed..11ddca639 100644
--- a/samples/SupportDesignDemos/res/layout/design_tabs_viewpager.xml
+++ b/samples/SupportDesignDemos/res/layout/design_tabs_viewpager.xml
@@ -54,13 +54,22 @@
android:id="@+id/btn_add_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/add_tab"/>
+ android:text="@string/add_tab"
+ android:onClick="addTab"/>
<Button
android:id="@+id/btn_remove_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/remove_tab"/>
+ android:text="@string/remove_tab"
+ android:onClick="removeTab"/>
+
+ <Button
+ android:id="@+id/btn_select_first_tab"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/select_first_tab"
+ android:onClick="selectFirstTab"/>
</LinearLayout>
diff --git a/samples/SupportDesignDemos/res/layout/design_text_input.xml b/samples/SupportDesignDemos/res/layout/design_text_input.xml
index 4561df125..32260746f 100644
--- a/samples/SupportDesignDemos/res/layout/design_text_input.xml
+++ b/samples/SupportDesignDemos/res/layout/design_text_input.xml
@@ -36,6 +36,24 @@
</android.support.design.widget.TextInputLayout>
+ <LinearLayout android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/show_error"
+ android:onClick="showError"/>
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/clear_error"
+ android:onClick="clearError"/>
+
+ </LinearLayout>
+
<android.support.design.widget.TextInputLayout
android:id="@+id/input_email"
android:layout_width="match_parent"
@@ -51,16 +69,20 @@
</android.support.design.widget.TextInputLayout>
- <Button
- android:layout_width="wrap_content"
+ <android.support.design.widget.TextInputLayout
+ android:id="@+id/input_description"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/show_error"
- android:onClick="showError"/>
+ android:layout_marginTop="8dp"
+ app:counterEnabled="true"
+ app:counterMaxLength="30">
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/clear_error"
- android:onClick="clearError"/>
+ <EditText
+ android:id="@+id/edit_description"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:hint="@string/form_description"/>
+
+ </android.support.design.widget.TextInputLayout>
</LinearLayout> \ No newline at end of file
diff --git a/samples/SupportDesignDemos/res/menu/navigation.xml b/samples/SupportDesignDemos/res/menu/navigation.xml
index b399ef3a9..6425b1893 100644
--- a/samples/SupportDesignDemos/res/menu/navigation.xml
+++ b/samples/SupportDesignDemos/res/menu/navigation.xml
@@ -14,7 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- Main items -->
<group android:checkableBehavior="single">
@@ -30,7 +31,8 @@
<item
android:id="@+id/navigation_item_3"
android:icon="@drawable/ic_android"
- android:title="@string/navigation_item_3"/>
+ android:title="@string/navigation_item_3"
+ app:actionLayout="@layout/action_layout"/>
<item
android:id="@+id/navigation_item_disabled"
android:icon="@drawable/ic_android"
diff --git a/samples/SupportDesignDemos/res/values-w540dp/dimens.xml b/samples/SupportDesignDemos/res/values-w540dp/dimens.xml
new file mode 100644
index 000000000..26fecbf04
--- /dev/null
+++ b/samples/SupportDesignDemos/res/values-w540dp/dimens.xml
@@ -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>
+ <dimen name="bottom_sheet_horizontal_margin">64dp</dimen>
+</resources>
diff --git a/samples/SupportDesignDemos/res/values/dimens.xml b/samples/SupportDesignDemos/res/values/dimens.xml
new file mode 100644
index 000000000..ac8777cfe
--- /dev/null
+++ b/samples/SupportDesignDemos/res/values/dimens.xml
@@ -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>
+ <dimen name="bottom_sheet_horizontal_margin">0dp</dimen>
+</resources>
diff --git a/samples/SupportDesignDemos/res/values/strings.xml b/samples/SupportDesignDemos/res/values/strings.xml
index 16b17172a..c3a981a02 100644
--- a/samples/SupportDesignDemos/res/values/strings.xml
+++ b/samples/SupportDesignDemos/res/values/strings.xml
@@ -21,6 +21,7 @@
<string name="design_navigation">NavigationView/Usage</string>
<string name="design_tabs_basic">TabLayout/Usage</string>
<string name="design_text_input">Text Input</string>
+ <string name="design_bottomsheet">BottomSheet/Usage</string>
<string name="fab_size_normal">Normal size</string>
<string name="fab_size_mini">Mini size</string>
@@ -48,9 +49,11 @@
<string name="add_tab">Add tab</string>
<string name="remove_tab">Remove tab</string>
+ <string name="select_first_tab">Select tab #0</string>
<string name="form_username">Username</string>
<string name="form_email">Email address</string>
+ <string name="form_description">Description</string>
<string name="show_error">Show error</string>
<string name="clear_error">Clear error</string>
@@ -64,11 +67,13 @@
<string name="snackbar_show_long_long_action">Show (long message + long action)</string>
<string name="design_appbar_toolbar_scroll_tabs_scroll">AppBar/Toolbar Scroll + Tabs Scroll</string>
+ <string name="design_appbar_toolbar_scroll_tabs_scroll_snap">AppBar/Toolbar Scroll + Tabs Scroll + Snap</string>
<string name="design_appbar_toolbar_scroll_tabs_pin">AppBar/Toolbar Scroll + Tabs Pin</string>
<string name="design_appbar_toolbar_scroll_tabs_pin_with_swiperefresh">AppBar/Toolbar Scroll + Tabs Pin + Swipe Refresh</string>
<string name="design_appbar_collapsing_toolbar_pin">AppBar/Collapsing Toolbar (pinned)</string>
<string name="design_appbar_collapsing_toolbar_pin_fab">AppBar/Collapsing Toolbar (pinned with FAB)</string>
<string name="design_appbar_collapsing_toolbar_scroll">AppBar/Collapsing Toolbar (scroll off)</string>
+ <string name="design_appbar_collapsing_toolbar_scroll_with_swiperefresh">AppBar/Collapsing Toolbar (scroll off) + Swipe Refresh</string>
<string name="design_appbar_collapsing_toolbar_with_image">AppBar/Collapsing Toolbar + Parallax Image</string>
<string name="design_appbar_collapsing_toolbar_with_image_insets">AppBar/Collapsing Toolbar + Parallax Image + Insets</string>
<string name="design_appbar_parallax_overlap">AppBar/Parallax Overlapping content</string>
@@ -77,5 +82,6 @@
<string name="menu_search">Search</string>
<string name="menu_settings">Settings</string>
+ <string name="bottom_sheet">Bottom sheet</string>
</resources>
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenScrollWithSwipeRefresh.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenScrollWithSwipeRefresh.java
new file mode 100644
index 000000000..bed269b87
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenScrollWithSwipeRefresh.java
@@ -0,0 +1,27 @@
+/*
+ * 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.design.widget;
+
+import com.example.android.support.design.R;
+
+public class AppBarLayoutToolbarCollapseThenScrollWithSwipeRefresh extends AppBarLayoutUsageBase {
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.design_appbar_toolbar_collapse_scroll_with_swiperefresh;
+ }
+}
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsScrollSnap.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsScrollSnap.java
new file mode 100644
index 000000000..710a80abb
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsScrollSnap.java
@@ -0,0 +1,27 @@
+/*
+ * 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.design.widget;
+
+import com.example.android.support.design.R;
+
+public class AppBarLayoutToolbarScrollTabsScrollSnap extends AppBarLayoutUsageBase {
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.design_appbar_toolbar_scroll_tabs_scroll_snap;
+ }
+}
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetUsage.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetUsage.java
new file mode 100644
index 000000000..21f6ffe62
--- /dev/null
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomSheetUsage.java
@@ -0,0 +1,54 @@
+/*
+ * 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.design.widget;
+
+import com.example.android.support.design.R;
+import com.example.android.support.design.Shakespeare;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.design.widget.BottomSheetBehavior;
+import android.support.v7.app.AppCompatActivity;
+import android.text.TextUtils;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+/**
+ * This demonstrates basic usage of {@link BottomSheetBehavior}.
+ */
+public class BottomSheetUsage extends AppCompatActivity {
+
+ private BottomSheetBehavior<LinearLayout> mBehavior;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.design_bottom_sheet);
+ ((TextView) findViewById(R.id.dialogue)).setText(TextUtils.concat(Shakespeare.DIALOGUE));
+ mBehavior = BottomSheetBehavior.from((LinearLayout) findViewById(R.id.bottom_sheet));
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (mBehavior != null && mBehavior.getState() != BottomSheetBehavior.STATE_COLLAPSED) {
+ mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
+ } else {
+ super.onBackPressed();
+ }
+ }
+
+}
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java
index ef776e0c6..26b61083f 100644
--- a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java
@@ -21,8 +21,6 @@ import com.example.android.support.design.R;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
-import android.support.design.widget.TabLayout.TabLayoutOnPageChangeListener;
-import android.support.design.widget.TabLayout.ViewPagerOnTabSelectedListener;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
@@ -46,6 +44,8 @@ public class TabLayoutUsage extends AppCompatActivity {
private ViewPager mViewPager;
private CheesePagerAdapter mPagerAdapter;
+ private final Random mRandom = new Random();
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -57,41 +57,29 @@ public class TabLayoutUsage extends AppCompatActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mTabLayout = (TabLayout) findViewById(R.id.tabs);
-
mViewPager = (ViewPager) findViewById(R.id.tabs_viewpager);
+
mPagerAdapter = new CheesePagerAdapter();
mViewPager.setAdapter(mPagerAdapter);
- mViewPager.setOnPageChangeListener(new TabLayoutOnPageChangeListener(mTabLayout));
- mTabLayout.setOnTabSelectedListener(new ViewPagerOnTabSelectedListener(mViewPager));
- setupButtons();
+ mTabLayout.setupWithViewPager(mViewPager);
+
setupRadioGroup();
}
- private void setupButtons() {
- findViewById(R.id.btn_add_tab).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- addRandomTab();
- }
- });
+ public void addTab(View view) {
+ String cheese = Cheeses.sCheeseStrings[mRandom.nextInt(Cheeses.sCheeseStrings.length)];
+ mPagerAdapter.addTab(cheese);
+ }
- findViewById(R.id.btn_remove_tab).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (mTabLayout.getTabCount() >= 1) {
- mTabLayout.removeTabAt(mTabLayout.getTabCount() - 1);
- mPagerAdapter.removeTab();
- }
- }
- });
+ public void selectFirstTab(View view) {
+ if (mTabLayout.getTabCount() > 0) {
+ mViewPager.setCurrentItem(0);
+ }
}
- private void addRandomTab() {
- Random r = new Random();
- String cheese = Cheeses.sCheeseStrings[r.nextInt(Cheeses.sCheeseStrings.length)];
- mTabLayout.addTab(mTabLayout.newTab().setText(cheese));
- mPagerAdapter.addTab(cheese);
+ public void removeTab(View view) {
+ mPagerAdapter.removeTab();
}
private void setupRadioGroup() {
@@ -147,7 +135,6 @@ public class TabLayoutUsage extends AppCompatActivity {
}
private static class CheesePagerAdapter extends PagerAdapter {
-
private final ArrayList<CharSequence> mCheeses = new ArrayList<>();
public void addTab(String title) {
@@ -168,21 +155,31 @@ public class TabLayoutUsage extends AppCompatActivity {
}
@Override
+ public int getItemPosition(Object object) {
+ final Item item = (Item) object;
+ final int index = mCheeses.indexOf(item.cheese);
+ return index >= 0 ? index : POSITION_NONE;
+ }
+
+ @Override
public Object instantiateItem(ViewGroup container, int position) {
- TextView tv = new TextView(container.getContext());
+ final TextView tv = new TextView(container.getContext());
tv.setText(getPageTitle(position));
tv.setGravity(Gravity.CENTER);
tv.setTextAppearance(tv.getContext(), R.style.TextAppearance_AppCompat_Title);
-
container.addView(tv, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
- return tv;
+ Item item = new Item();
+ item.cheese = mCheeses.get(position);
+ item.view = tv;
+ return item;
}
@Override
public boolean isViewFromObject(View view, Object object) {
- return view == object;
+ final Item item = (Item) object;
+ return item.view == view;
}
@Override
@@ -192,7 +189,13 @@ public class TabLayoutUsage extends AppCompatActivity {
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
- container.removeView((View) object);
+ final Item item = (Item) object;
+ container.removeView(item.view);
+ }
+
+ private static class Item {
+ TextView view;
+ CharSequence cheese;
}
}