Add hide on scroll demo
Change-Id: I1c76ad7c5f2c37a4cdfde4e73b9579ec3a633fcb
diff --git a/samples/Support7Demos/AndroidManifest.xml b/samples/Support7Demos/AndroidManifest.xml
index a84dc22..26f2a57 100644
--- a/samples/Support7Demos/AndroidManifest.xml
+++ b/samples/Support7Demos/AndroidManifest.xml
@@ -222,6 +222,15 @@
</intent-filter>
</activity>
+ <activity android:name=".app.ActionBarHideOnScroll"
+ android:label="@string/action_bar_hide_scroll"
+ android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.supportv7.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
<activity android:name=".app.AppCompatWidgetsButtons"
android:label="@string/appcompat_widgets_buttons"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
diff --git a/samples/Support7Demos/res/drawable/gradient.xml b/samples/Support7Demos/res/drawable/gradient.xml
new file mode 100644
index 0000000..1b654a0
--- /dev/null
+++ b/samples/Support7Demos/res/drawable/gradient.xml
@@ -0,0 +1,20 @@
+<?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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <gradient android:startColor="#FF0000"
+ android:endColor="#0000FF"
+ android:angle="270" />
+</shape>
\ No newline at end of file
diff --git a/samples/Support7Demos/res/layout/action_bar_hide_scroll.xml b/samples/Support7Demos/res/layout/action_bar_hide_scroll.xml
new file mode 100644
index 0000000..a80140f
--- /dev/null
+++ b/samples/Support7Demos/res/layout/action_bar_hide_scroll.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="2000dp"
+ android:background="@drawable/gradient" />
+
+ </LinearLayout>
+
+</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
diff --git a/samples/Support7Demos/res/values/strings.xml b/samples/Support7Demos/res/values/strings.xml
index 3480142..6e2c2f7 100644
--- a/samples/Support7Demos/res/values/strings.xml
+++ b/samples/Support7Demos/res/values/strings.xml
@@ -58,6 +58,7 @@
<string name="action_bar_with_navigation_drawer">AppCompat/Action Bar/Navigation Drawer Toggle</string>
<string name="action_bar_preferences">AppCompat/Action Bar/Preferences</string>
<string name="action_bar_action_mode">AppCompat/Action Bar/Action Mode</string>
+ <string name="action_bar_hide_scroll">AppCompat/Action Bar/Hide on Scroll</string>
<string name="appcompat_widgets_buttons">AppCompat/Widgets/Buttons</string>
<string name="appcompat_widgets_spinners">AppCompat/Widgets/Spinners</string>
<string name="appcompat_widgets_text_input">AppCompat/Widgets/Text Input</string>
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarHideOnScroll.java b/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarHideOnScroll.java
new file mode 100644
index 0000000..61bd90b
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarHideOnScroll.java
@@ -0,0 +1,42 @@
+/*
+ * 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.supportv7.app;
+
+import com.example.android.supportv7.R;
+
+import android.os.Bundle;
+import android.support.v4.view.WindowCompat;
+import android.support.v7.app.AppCompatActivity;
+
+/**
+ * This demonstrates usage of the Action Bar's hide on content scroll
+ */
+public class ActionBarHideOnScroll extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Hide on content scroll requires an overlay action bar, so request one
+ supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY);
+
+ setContentView(R.layout.action_bar_hide_scroll);
+
+ // Enable hide on scroll
+ getSupportActionBar().setHideOnContentScrollEnabled(true);
+ }
+
+}