diff options
author | Chris Banes <chrisbanes@google.com> | 2015-05-06 07:02:43 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-06 07:02:44 +0000 |
commit | 809b0d756b287207a1c6987fbd365e9822a8baf6 (patch) | |
tree | 5f04d79364a1eb1b8e4a33446403a030298e94cd /samples/SupportDesignDemos | |
parent | 1063d9b435f91ebc8306c407cfa0a82223beb148 (diff) | |
parent | 2194f821f0d7a381fb74387e1ea423f0e1b2aa0d (diff) | |
download | android_development-809b0d756b287207a1c6987fbd365e9822a8baf6.tar.gz android_development-809b0d756b287207a1c6987fbd365e9822a8baf6.tar.bz2 android_development-809b0d756b287207a1c6987fbd365e9822a8baf6.zip |
Merge "AppBarLayout demo" into lmp-mr1-ub-dev
Diffstat (limited to 'samples/SupportDesignDemos')
24 files changed, 951 insertions, 0 deletions
diff --git a/samples/SupportDesignDemos/Android.mk b/samples/SupportDesignDemos/Android.mk index 6da181150..f70b6e138 100644 --- a/samples/SupportDesignDemos/Android.mk +++ b/samples/SupportDesignDemos/Android.mk @@ -25,13 +25,16 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_STATIC_JAVA_LIBRARIES := \ android-support-v4 \ android-support-v7-appcompat \ + android-support-v7-recyclerview \ android-support-design LOCAL_RESOURCE_DIR = \ $(LOCAL_PATH)/res \ frameworks/support/v7/appcompat/res \ + frameworks/support/v7/recyclerview/res \ frameworks/support/design/res LOCAL_AAPT_FLAGS := \ --auto-add-overlay \ --extra-packages android.support.v7.appcompat \ + --extra-packages android.support.v7.recyclerview \ --extra-packages android.support.design include $(BUILD_PACKAGE) diff --git a/samples/SupportDesignDemos/AndroidManifest.xml b/samples/SupportDesignDemos/AndroidManifest.xml index 58829485b..a3492358b 100644 --- a/samples/SupportDesignDemos/AndroidManifest.xml +++ b/samples/SupportDesignDemos/AndroidManifest.xml @@ -99,5 +99,68 @@ </intent-filter> </activity> + <activity android:name=".widget.AppBarLayoutToolbarScrollTabsScroll" + android:label="@string/design_appbar_toolbar_scroll_tabs_scroll" + 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"> + <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.AppBarLayoutToolbarCollapseThenPin" + android:label="@string/design_appbar_collapsing_toolbar_pin" + 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.AppBarLayoutToolbarCollapseThenPinWithFab" + android:label="@string/design_appbar_collapsing_toolbar_pin_fab" + 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.AppBarLayoutToolbarCollapseThenScroll" + android:label="@string/design_appbar_collapsing_toolbar_scroll" + 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"> + <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.AppBarLayoutToolbarParallaxOverlapContent" + android:label="@string/design_appbar_parallax_overlap" + 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/res/drawable-nodpi/photo.jpg b/samples/SupportDesignDemos/res/drawable-nodpi/photo.jpg Binary files differnew file mode 100644 index 000000000..d5a2ef094 --- /dev/null +++ b/samples/SupportDesignDemos/res/drawable-nodpi/photo.jpg diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_pin.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_pin.xml new file mode 100644 index 000000000..d41c20ba3 --- /dev/null +++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_pin.xml @@ -0,0 +1,47 @@ +<?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:layout_width="match_parent" + android:layout_height="match_parent"> + + <android.support.design.widget.AppBarLayout + android:layout_height="wrap_content" + 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="192dp" + app:layout_scrollFlags="scroll|exitUntilCollapsed"> + + <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"/> + +</android.support.design.widget.CoordinatorLayout> diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_pin_with_fab.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_pin_with_fab.xml new file mode 100644 index 000000000..ac03794a5 --- /dev/null +++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_pin_with_fab.xml @@ -0,0 +1,58 @@ +<?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:layout_width="match_parent" + android:layout_height="match_parent"> + + <android.support.design.widget.AppBarLayout + android:id="@+id/appbar" + android:layout_height="wrap_content" + 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="192dp" + app:layout_scrollFlags="scroll|exitUntilCollapsed"> + + <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_scrollview"/> + + <android.support.design.widget.FloatingActionButton + android:layout_height="wrap_content" + android:layout_width="wrap_content" + app:layout_anchor="@id/appbar" + app:layout_anchorGravity="bottom|right|end" + android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha" + android:layout_marginRight="16dp" + android:clickable="true" + app:fabSize="mini"/> + +</android.support.design.widget.CoordinatorLayout> diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_scroll.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_scroll.xml new file mode 100644 index 000000000..560dee0ca --- /dev/null +++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_scroll.xml @@ -0,0 +1,46 @@ +<?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:layout_width="match_parent" + android:layout_height="match_parent"> + + <android.support.design.widget.AppBarLayout + android:layout_height="wrap_content" + 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="192dp" + 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_scrollview"/> + +</android.support.design.widget.CoordinatorLayout> diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_with_image.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_with_image.xml new file mode 100644 index 000000000..66cad426a --- /dev/null +++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_collapse_with_image.xml @@ -0,0 +1,56 @@ +<?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:layout_width="match_parent" + android:layout_height="match_parent"> + + <android.support.design.widget.AppBarLayout + android:layout_height="wrap_content" + 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="192dp" + app:layout_scrollFlags="scroll|exitUntilCollapsed" + app:foregroundScrimColor="?attr/colorPrimary"> + + <ImageView + android:id="@+id/app_bar_image" + android:layout_width="match_parent" + android:layout_height="match_parent" + app:layout_collapseMode="parallax" + android:src="@drawable/photo" + android:scaleType="centerCrop"/> + + <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_scrollview"/> + +</android.support.design.widget.CoordinatorLayout> diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_parallax_overlap.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_parallax_overlap.xml new file mode 100644 index 000000000..ff21686b5 --- /dev/null +++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_parallax_overlap.xml @@ -0,0 +1,56 @@ +<?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:layout_width="match_parent" + android:layout_height="match_parent"> + + <android.support.design.widget.AppBarLayout + android:layout_height="wrap_content" + 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="192dp" + app:layout_scrollFlags="scroll|exitUntilCollapsed" + app:layout_scrollInterpolator="@android:anim/decelerate_interpolator" + app:foregroundScrimColor="?attr/colorPrimary"> + + <ImageView + android:id="@+id/app_bar_image" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:src="@drawable/photo" + android:scaleType="centerCrop"/> + + <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_scrollview_with_image" /> + +</android.support.design.widget.CoordinatorLayout> diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_pinned.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_pinned.xml new file mode 100644 index 000000000..ea94c8ab5 --- /dev/null +++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_pinned.xml @@ -0,0 +1,46 @@ +<?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:layout_width="match_parent" + android:layout_height="match_parent"> + + <android.support.design.widget.AppBarLayout + 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"/> + + <android.support.design.widget.TabLayout + android:id="@+id/tabs" + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:tabMode="scrollable"/> + + </android.support.design.widget.AppBarLayout> + + <include layout="@layout/include_appbar_recyclerview"/> + +</android.support.design.widget.CoordinatorLayout> + diff --git a/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_scroll.xml b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_scroll.xml new file mode 100644 index 000000000..580c5c4c4 --- /dev/null +++ b/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_scroll_tabs_scroll.xml @@ -0,0 +1,47 @@ +<?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:layout_width="match_parent" + android:layout_height="match_parent"> + + <android.support.design.widget.AppBarLayout + 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"/> + + <android.support.design.widget.TabLayout + android:id="@+id/tabs" + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:layout_scrollFlags="scroll|enterAlways" + 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/include_appbar_recyclerview.xml b/samples/SupportDesignDemos/res/layout/include_appbar_recyclerview.xml new file mode 100644 index 000000000..ab255e45a --- /dev/null +++ b/samples/SupportDesignDemos/res/layout/include_appbar_recyclerview.xml @@ -0,0 +1,22 @@ +<?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.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@+id/appbar_recyclerview" + android:layout_width="match_parent" + android:layout_height="match_parent" + app:layout_behavior="@string/appbar_scrolling_view_behavior" />
\ No newline at end of file diff --git a/samples/SupportDesignDemos/res/layout/include_appbar_scrollview.xml b/samples/SupportDesignDemos/res/layout/include_appbar_scrollview.xml new file mode 100644 index 000000000..b10752a5c --- /dev/null +++ b/samples/SupportDesignDemos/res/layout/include_appbar_scrollview.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.v4.widget.NestedScrollView 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" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="1000dp" + android:orientation="vertical"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:text="@string/scroll_top" /> + + <TextView + android:id="@+id/textview_dialogue" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp"/> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:text="@string/scroll_bottom" /> + + </LinearLayout> + +</android.support.v4.widget.NestedScrollView>
\ No newline at end of file diff --git a/samples/SupportDesignDemos/res/layout/include_appbar_scrollview_with_image.xml b/samples/SupportDesignDemos/res/layout/include_appbar_scrollview_with_image.xml new file mode 100644 index 000000000..a5392b245 --- /dev/null +++ b/samples/SupportDesignDemos/res/layout/include_appbar_scrollview_with_image.xml @@ -0,0 +1,42 @@ +<?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.widget.NestedScrollView 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" + app:layout_behavior="@string/appbar_scrolling_view_behavior" + app:behavior_overlapTop="32dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="1000dp" + android:orientation="vertical"> + + <ImageView android:layout_width="72dp" + android:layout_height="72dp" + android:src="@drawable/app_sample_code" + android:layout_marginLeft="16dp"/> + + <TextView + android:id="@+id/textview_dialogue" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp"/> + + </LinearLayout> + +</android.support.v4.widget.NestedScrollView>
\ No newline at end of file diff --git a/samples/SupportDesignDemos/res/menu/sample_actions.xml b/samples/SupportDesignDemos/res/menu/sample_actions.xml new file mode 100644 index 000000000..280005ab9 --- /dev/null +++ b/samples/SupportDesignDemos/res/menu/sample_actions.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 Google Inc. + + 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. +--> +<menu xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> + <item android:id="@+id/action_search" + android:title="@string/menu_search" + android:icon="@drawable/abc_ic_search_api_mtrl_alpha" + app:showAsAction="ifRoom"/> + <item android:id="@+id/action_settings" + android:title="@string/menu_settings" + app:showAsAction="never"/> +</menu> diff --git a/samples/SupportDesignDemos/res/values/strings.xml b/samples/SupportDesignDemos/res/values/strings.xml index 2d2f1b792..52eadf0cb 100644 --- a/samples/SupportDesignDemos/res/values/strings.xml +++ b/samples/SupportDesignDemos/res/values/strings.xml @@ -63,4 +63,17 @@ <string name="snackbar_show_long_action">Show (long message + action)</string> <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_pin">AppBar/Toolbar Scroll + Tabs Pin</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_with_image">AppBar/Collapsing Toolbar + Parallax Image</string> + <string name="design_appbar_parallax_overlap">AppBar/Parallax Overlapping content</string> + <string name="scroll_top">Top</string> + <string name="scroll_bottom">Bottom</string> + <string name="menu_search">Search</string> + <string name="menu_settings">Settings</string> + + </resources> diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenPin.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenPin.java new file mode 100644 index 000000000..24038524f --- /dev/null +++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenPin.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 AppBarLayoutToolbarCollapseThenPin extends AppBarLayoutUsageBase { + + @Override + protected int getLayoutId() { + return R.layout.design_appbar_toolbar_collapse_pin; + } +} diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenPinWithFab.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenPinWithFab.java new file mode 100644 index 000000000..97a7a77bf --- /dev/null +++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenPinWithFab.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 AppBarLayoutToolbarCollapseThenPinWithFab extends AppBarLayoutUsageBase { + + @Override + protected int getLayoutId() { + return R.layout.design_appbar_toolbar_collapse_pin_with_fab; + } +} diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenScroll.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenScroll.java new file mode 100644 index 000000000..2a4cd262b --- /dev/null +++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseThenScroll.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 AppBarLayoutToolbarCollapseThenScroll extends AppBarLayoutUsageBase { + + @Override + protected int getLayoutId() { + return R.layout.design_appbar_toolbar_collapse_scroll; + } +} diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseWithImage.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseWithImage.java new file mode 100644 index 000000000..8a1127884 --- /dev/null +++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarCollapseWithImage.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 AppBarLayoutToolbarCollapseWithImage extends AppBarLayoutUsageBase { + + @Override + protected int getLayoutId() { + return R.layout.design_appbar_toolbar_collapse_with_image; + } +} diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarParallaxOverlapContent.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarParallaxOverlapContent.java new file mode 100644 index 000000000..8e45a367d --- /dev/null +++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarParallaxOverlapContent.java @@ -0,0 +1,32 @@ +/* + * 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 AppBarLayoutToolbarParallaxOverlapContent extends AppBarLayoutUsageBase { + + @Override + protected int getLayoutId() { + return R.layout.design_appbar_toolbar_parallax_overlap; + } + + @Override + protected boolean displayTitle() { + return false; + } +} diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsPin.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsPin.java new file mode 100644 index 000000000..f153d8bc2 --- /dev/null +++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsPin.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 AppBarLayoutToolbarScrollTabsPin extends AppBarLayoutUsageBase { + + @Override + protected int getLayoutId() { + return R.layout.design_appbar_toolbar_scroll_tabs_pinned; + } +} diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsScroll.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsScroll.java new file mode 100644 index 000000000..f48031f6d --- /dev/null +++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutToolbarScrollTabsScroll.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 AppBarLayoutToolbarScrollTabsScroll extends AppBarLayoutUsageBase { + + @Override + protected int getLayoutId() { + return R.layout.design_appbar_toolbar_scroll_tabs_scroll; + } +} diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutUsageBase.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutUsageBase.java new file mode 100644 index 000000000..f91ef5121 --- /dev/null +++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/AppBarLayoutUsageBase.java @@ -0,0 +1,98 @@ +/* + * 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.Cheeses; +import com.example.android.support.design.R; +import com.example.android.support.design.Shakespeare; + +import android.os.Bundle; +import android.support.design.widget.CollapsingToolbarLayout; +import android.support.design.widget.TabLayout; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.text.TextUtils; +import android.view.Menu; +import android.widget.TextView; + +import java.util.Random; + +abstract class AppBarLayoutUsageBase extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(getLayoutId()); + + // Retrieve the Toolbar from our content view, and set it as the action bar + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) + findViewById(R.id.collapsing_app_bar); + if (appBarLayout != null && displayTitle()) { + appBarLayout.setTitle(getTitle()); + } + + TextView dialog = (TextView) findViewById(R.id.textview_dialogue); + if (dialog != null) { + dialog.setText(TextUtils.concat(Shakespeare.DIALOGUE)); + } + + RecyclerView recyclerView = (RecyclerView) findViewById(R.id.appbar_recyclerview); + if (recyclerView != null) { + setupRecyclerView(recyclerView); + } + + TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); + if (tabLayout != null) { + setupTabs(tabLayout); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.sample_actions, menu); + return true; + } + + private void addRandomTab(TabLayout tabLayout) { + Random r = new Random(); + String cheese = Cheeses.sCheeseStrings[r.nextInt(Cheeses.sCheeseStrings.length)]; + tabLayout.addTab(tabLayout.newTab().setText(cheese)); + } + + private void setupTabs(TabLayout tabLayout) { + for (int i = 0; i < 10; i++) { + addRandomTab(tabLayout); + } + } + + private void setupRecyclerView(RecyclerView recyclerView) { + recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext())); + recyclerView.setAdapter(new SimpleStringRecyclerViewAdapter(this, Cheeses.sCheeseStrings)); + } + + protected boolean displayTitle() { + return true; + } + + protected abstract int getLayoutId(); + +} diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/SimpleStringRecyclerViewAdapter.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/SimpleStringRecyclerViewAdapter.java new file mode 100644 index 000000000..2f9b79f8f --- /dev/null +++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/SimpleStringRecyclerViewAdapter.java @@ -0,0 +1,87 @@ +/* + * 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 android.content.Context; +import android.graphics.Color; +import android.support.v7.widget.RecyclerView; +import android.text.Layout; +import android.util.TypedValue; +import android.view.LayoutInflater; +import android.view.ViewGroup; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.Collections; + +public class SimpleStringRecyclerViewAdapter + extends RecyclerView.Adapter<SimpleStringRecyclerViewAdapter.ViewHolder> { + + private int mBackground; + + private ArrayList<String> mValues; + + public static class ViewHolder extends RecyclerView.ViewHolder { + public String mBoundString; + public TextView mTextView; + + public ViewHolder(TextView v) { + super(v); + mTextView = v; + } + + @Override + public String toString() { + return super.toString() + " '" + mTextView.getText(); + } + } + + public String getValueAt(int position) { + return mValues.get(position); + } + + public SimpleStringRecyclerViewAdapter(Context context, String[] strings) { + TypedValue val = new TypedValue(); + if (context.getTheme() != null) { + context.getTheme().resolveAttribute(R.attr.selectableItemBackground, val, true); + } + mBackground = val.resourceId; + mValues = new ArrayList<>(); + Collections.addAll(mValues, strings); + } + + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + TextView textView = (TextView) LayoutInflater.from(parent.getContext()) + .inflate(android.R.layout.simple_list_item_1, parent, false); + textView.setBackgroundResource(mBackground); + return new ViewHolder(textView); + } + + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + holder.mBoundString = mValues.get(position); + holder.mTextView.setText(position + ": " + mValues.get(position)); + } + + @Override + public int getItemCount() { + return mValues.size(); + } +} |