Android Training--Managing the System UI
来源:互联网 发布:mac怎么安装ipython 编辑:程序博客网 时间:2024/06/06 21:44
Dimming the System Bars
This lesson describes how to dim the system bars (that is, the status and the navigation bars) on Android 4.0 (API level 14) and higher. Android does not provide a built-in way to dim the system bars on earlier versions.
When you use this approach, the content doesn’t resize, but the icons in the system bars visually recede. As soon as the user touches either the status bar or the navigation bar area of the screen, both bars become fully visible. The advantage of this approach is that the bars are still present but their details are obscured, thus creating an immersive experience without sacrificing easy access to the bars.
Dimming the System Bars
You can dim the status and notification bars using the SYSTEM_UI_FLAG_LOW_PROFILE flag, as follows:
// This example uses decor view, but you can use any visible view.View decorView = getActivity().getWindow().getDecorView();int uiOptions = View.SYSTEM_UI_FLAG_LOW_PROFILE;decorView.setSystemUiVisibility(uiOptions);
As soon as the user touches the status or navigation bar, the flag is cleared, causing the bars to be undimmed. Once the flag has been cleared, your app needs to reset it if you want to dim the bars again.
Reveal the Status and Navigation Bars
If you want to programmatically clear flags set with setSystemUiVisibility(), you can do so as follows:
View decorView = getActivity().getWindow().getDecorView();// Calling setSystemUiVisibility() with a value of 0 clears// all flags.decorView.setSystemUiVisibility(0);
Hiding the Status Bar
This lesson describes how to hide the status bar on different versions of Android. Hiding the status bar (and optionally, the navigation bar) lets the content use more of the display space, thereby providing a more immersive user experience.
Figure 2 shows an app with a hidden status bar. Note that the action bar is hidden too. You should never show the action bar without the status bar.
Hide the Status Bar on Android 4.0 and Lower
You can hide the status bar on Android 4.0 (API level 14) and lower by setting WindowManager flags. You can do this programmatically or by setting an activity theme in your app’s manifest file. Setting an activity theme in your app’s manifest file is the preferred approach if the status bar should always remain hidden in your app (though strictly speaking, you could programmatically override the theme if you wanted to). For example:
<application ... android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" > ...</application>
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // If the Android version is lower than Jellybean, use this call to hide // the status bar. if (Build.VERSION.SDK_INT < 16) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } setContentView(R.layout.activity_main); } ...}
Hide the Status Bar on Android 4.1 and Higher
You can hide the status bar on Android 4.1 (API level 16) and higher by using setSystemUiVisibility(). setSystemUiVisibility() sets UI flags at the individual view level; these settings are aggregated to the window level. Using setSystemUiVisibility() to set UI flags gives you more granular control over the system bars than using WindowManager flags. This snippet hides the status bar:
View decorView = getWindow().getDecorView();// Hide the status bar.int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;decorView.setSystemUiVisibility(uiOptions);// Remember that you should never show the action bar if the// status bar is hidden, so hide that too if necessary.ActionBar actionBar = getActionBar();actionBar.hide();
后面还有一些内容, 感觉近期不太使用的到, 先不继续研究了, 以后再补齐吧.
- Android Training--Managing the System UI
- Managing the System UI
- Managing the System UI -
- Android Develop Training——管理Activity的生命周期(Managing the Activity Lifecycle)
- Android官方Training阅读笔记 ---- Managing the Activity Lifecycle(Starting an Activity) (一)
- Android官方Training阅读笔记 ---- Managing the Activity Lifecycle(Pausing and Resuming an Activity) (二)
- Android官方Training阅读笔记 ---- Managing the Activity Lifecycle(Stopping and Restarting an Activity) (三)
- Android官方Training阅读笔记 ---- Managing the Activity Lifecycle(Recreating an Activity) (四)
- android-Managing the Activity Lifecycle
- Develop--Training(四)Getting Started--Managing the Activity Lifecycle
- Managing Projects from the Command Line(android官网文档)
- Android官方文档翻译 十六 4.Managing the Activity Lifecycle
- SWT: The Standard Widget Toolkit -- PART 2: Managing Operating System Resources
- Managing the Undo Tablespace
- Managing the Keyboard
- Managing the Keyboard
- Managing the Activity Lifecycle
- Managing the Activity Lifecycle
- iOS 中捕获程序崩溃日志
- 从什么都不懂开始(三) 实践带你飞之Branch操作
- 最小费用最大流详解与模板
- IOS应用架构思考二(网络图片库)
- Android Studio 如何打JAR包
- Android Training--Managing the System UI
- xcode6 制作动态和静态framework(涉及arms)
- Leetcode 75. Sort Colors (Medium) (cpp)
- hdu 3364 Lanterns 高斯消元,模板题
- HDU 4497 GCD and LCM(唯一分解定理+排列组合)
- C语言中各种数据类型和数据结构0727
- WinDBG技巧:在加载/卸载一个DLL 的时候下断点
- 某集团公司“产品设计之道”内训圆满结束结束!
- 学习C语言的第三天