Merge "Add hide on scroll demo" into lmp-mr1-ub-dev
This commit is contained in:
@@ -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">
|
||||
|
||||
20
samples/Support7Demos/res/drawable/gradient.xml
Normal file
20
samples/Support7Demos/res/drawable/gradient.xml
Normal file
@@ -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>
|
||||
33
samples/Support7Demos/res/layout/action_bar_hide_scroll.xml
Normal file
33
samples/Support7Demos/res/layout/action_bar_hide_scroll.xml
Normal file
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user