Add new action bar demos:
- Buttons for showing/hiding action bar and system UI in the basic action bar demo. - New system UI demo that uses a non-overlay action bar. Change-Id: Id3fbaa77365476489c558a2a43855a01f383551c
This commit is contained in:
@@ -2308,7 +2308,18 @@
|
|||||||
|
|
||||||
<activity android:name=".view.SystemUIModes"
|
<activity android:name=".view.SystemUIModes"
|
||||||
android:label="Views/System UI Visibility/System UI Modes"
|
android:label="Views/System UI Visibility/System UI Modes"
|
||||||
android:uiOptions="splitActionBarWhenNarrow">
|
android:uiOptions="splitActionBarWhenNarrow"
|
||||||
|
android:enabled="@bool/atLeastJellyBeanMR2">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".view.SystemUIModesOverlay"
|
||||||
|
android:label="Views/System UI Visibility/System UI Modes Overlay"
|
||||||
|
android:uiOptions="splitActionBarWhenNarrow"
|
||||||
|
android:enabled="@bool/atLeastJellyBean">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -2318,7 +2329,8 @@
|
|||||||
<activity android:name=".view.ContentBrowserActivity"
|
<activity android:name=".view.ContentBrowserActivity"
|
||||||
android:label="Views/System UI Visibility/Content Browser"
|
android:label="Views/System UI Visibility/Content Browser"
|
||||||
android:theme="@android:style/Theme.Holo.Light.DarkActionBar"
|
android:theme="@android:style/Theme.Holo.Light.DarkActionBar"
|
||||||
android:uiOptions="splitActionBarWhenNarrow">
|
android:uiOptions="splitActionBarWhenNarrow"
|
||||||
|
android:enabled="@bool/atLeastJellyBean">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -2328,7 +2340,8 @@
|
|||||||
<activity android:name=".view.VideoPlayerActivity"
|
<activity android:name=".view.VideoPlayerActivity"
|
||||||
android:label="Views/System UI Visibility/Video Player"
|
android:label="Views/System UI Visibility/Video Player"
|
||||||
android:theme="@android:style/Theme.Holo"
|
android:theme="@android:style/Theme.Holo"
|
||||||
android:uiOptions="splitActionBarWhenNarrow">
|
android:uiOptions="splitActionBarWhenNarrow"
|
||||||
|
android:enabled="@bool/atLeastJellyBean">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
|||||||
@@ -13,36 +13,47 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:orientation="vertical">
|
<LinearLayout android:layout_width="match_parent"
|
||||||
<Button android:id="@+id/toggle_home_as_up"
|
android:layout_height="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:orientation="vertical">
|
||||||
android:layout_height="wrap_content"
|
<Button android:id="@+id/toggle_home_as_up"
|
||||||
android:text="@string/toggle_home_as_up" />
|
android:layout_width="wrap_content"
|
||||||
<Button android:id="@+id/toggle_show_home"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:text="@string/toggle_home_as_up" />
|
||||||
android:layout_height="wrap_content"
|
<Button android:id="@+id/toggle_show_home"
|
||||||
android:text="@string/toggle_show_home" />
|
android:layout_width="wrap_content"
|
||||||
<Button android:id="@+id/toggle_use_logo"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:text="@string/toggle_show_home" />
|
||||||
android:layout_height="wrap_content"
|
<Button android:id="@+id/toggle_use_logo"
|
||||||
android:text="@string/toggle_use_logo" />
|
android:layout_width="wrap_content"
|
||||||
<Button android:id="@+id/toggle_show_title"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:text="@string/toggle_use_logo" />
|
||||||
android:layout_height="wrap_content"
|
<Button android:id="@+id/toggle_show_title"
|
||||||
android:text="@string/toggle_show_title" />
|
android:layout_width="wrap_content"
|
||||||
<Button android:id="@+id/toggle_show_custom"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:text="@string/toggle_show_title" />
|
||||||
android:layout_height="wrap_content"
|
<Button android:id="@+id/toggle_show_custom"
|
||||||
android:text="@string/toggle_show_custom" />
|
android:layout_width="wrap_content"
|
||||||
<Button android:id="@+id/toggle_navigation"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:text="@string/toggle_show_custom" />
|
||||||
android:layout_height="wrap_content"
|
<Button android:id="@+id/toggle_navigation"
|
||||||
android:text="@string/toggle_navigation" />
|
android:layout_width="wrap_content"
|
||||||
<Button android:id="@+id/cycle_custom_gravity"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:text="@string/toggle_navigation" />
|
||||||
android:layout_height="wrap_content"
|
<Button android:id="@+id/cycle_custom_gravity"
|
||||||
android:text="@string/cycle_custom_gravity" />
|
android:layout_width="wrap_content"
|
||||||
</LinearLayout>
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/cycle_custom_gravity" />
|
||||||
|
<Button android:id="@+id/toggle_visibility"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/toggle_visibility" />
|
||||||
|
<Button android:id="@+id/toggle_system_ui"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/toggle_system_ui" />
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
@@ -847,6 +847,8 @@
|
|||||||
<string name="toggle_show_custom">DISPLAY_SHOW_CUSTOM</string>
|
<string name="toggle_show_custom">DISPLAY_SHOW_CUSTOM</string>
|
||||||
<string name="toggle_navigation">Navigation</string>
|
<string name="toggle_navigation">Navigation</string>
|
||||||
<string name="cycle_custom_gravity">Cycle Custom View Gravity</string>
|
<string name="cycle_custom_gravity">Cycle Custom View Gravity</string>
|
||||||
|
<string name="toggle_visibility">Toggle Visibility</string>
|
||||||
|
<string name="toggle_system_ui">Toggle System UI</string>
|
||||||
|
|
||||||
<string name="display_options_custom_button">Custom View!</string>
|
<string name="display_options_custom_button">Custom View!</string>
|
||||||
<string name="display_options_menu_item">Menu Item</string>
|
<string name="display_options_menu_item">Menu Item</string>
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ public class ActionBarDisplayOptions extends Activity
|
|||||||
findViewById(R.id.toggle_show_custom).setOnClickListener(this);
|
findViewById(R.id.toggle_show_custom).setOnClickListener(this);
|
||||||
findViewById(R.id.toggle_navigation).setOnClickListener(this);
|
findViewById(R.id.toggle_navigation).setOnClickListener(this);
|
||||||
findViewById(R.id.cycle_custom_gravity).setOnClickListener(this);
|
findViewById(R.id.cycle_custom_gravity).setOnClickListener(this);
|
||||||
|
findViewById(R.id.toggle_visibility).setOnClickListener(this);
|
||||||
|
findViewById(R.id.toggle_system_ui).setOnClickListener(this);
|
||||||
|
|
||||||
mCustomView = getLayoutInflater().inflate(R.layout.action_bar_display_options_custom, null);
|
mCustomView = getLayoutInflater().inflate(R.layout.action_bar_display_options_custom, null);
|
||||||
// Configure several action bar elements that will be toggled by display options.
|
// Configure several action bar elements that will be toggled by display options.
|
||||||
@@ -107,6 +109,22 @@ public class ActionBarDisplayOptions extends Activity
|
|||||||
lp.gravity = lp.gravity & ~Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK | newGravity;
|
lp.gravity = lp.gravity & ~Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK | newGravity;
|
||||||
bar.setCustomView(mCustomView, lp);
|
bar.setCustomView(mCustomView, lp);
|
||||||
return;
|
return;
|
||||||
|
case R.id.toggle_visibility:
|
||||||
|
if (bar.isShowing()) {
|
||||||
|
bar.hide();
|
||||||
|
} else {
|
||||||
|
bar.show();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case R.id.toggle_system_ui:
|
||||||
|
if ((getWindow().getDecorView().getSystemUiVisibility()
|
||||||
|
& View.SYSTEM_UI_FLAG_FULLSCREEN) != 0) {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(0);
|
||||||
|
} else {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(
|
||||||
|
View.SYSTEM_UI_FLAG_FULLSCREEN);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int change = bar.getDisplayOptions() ^ flags;
|
int change = bar.getDisplayOptions() ^ flags;
|
||||||
|
|||||||
@@ -166,8 +166,6 @@ public class SystemUIModes extends Activity
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
|
|
||||||
|
|
||||||
setContentView(R.layout.system_ui_modes);
|
setContentView(R.layout.system_ui_modes);
|
||||||
mImage = (IV) findViewById(R.id.image);
|
mImage = (IV) findViewById(R.id.image);
|
||||||
mImage.setActivity(this);
|
mImage.setActivity(this);
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 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.apis.view;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Window;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version of demo that uses the action bar in overlay mode.
|
||||||
|
*/
|
||||||
|
public class SystemUIModesOverlay extends SystemUIModes {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user