Android 4.0 隐藏虚拟按键(导航栏)的方法 .
来源:互联网 发布:ipad air清理缓存软件 编辑:程序博客网 时间:2024/05/22 08:27
在Android4.0里,多了一些API,其中包括怎样隐藏虚拟按键(导航栏),这样编写游戏或一个视频播放器时,可以设置隐藏虚拟按键的参数,达到最佳效果,当然前提是使用的手机是有虚拟按键的,例如galaxy nexus(i9250)。好吧,看一看官方的Android4.0 api说明就明白了。
Controls for system UI visibility
Since the early days of Android, the system has managed a UI component known as the status bar, which resides at the top of handset devices to deliver information such as the carrier signal, time, notifications, and so on. Android 3.0 added the system bar for tablet devices, which resides at the bottom of the screen to provide system navigation controls (Home, Back, and so forth) and also an interface for elements traditionally provided by the status bar. In Android 4.0, the system provides a new type of system UI called the navigation bar. You might consider the navigation bar a re-tuned version of the system bar designed for handsets—it provides navigation controls for devices that don’t have hardware counterparts for navigating the system, but it leaves out the system bar's notification UI and setting controls. As such, a device that provides the navigation bar also has the status bar at the top.
To this day, you can hide the status bar on handsets using the FLAG_FULLSCREEN
flag. In Android 4.0, the APIs that control the system bar’s visibility have been updated to better reflect the behavior of both the system bar and navigation bar:
- The
SYSTEM_UI_FLAG_LOW_PROFILE
flag replaces theSTATUS_BAR_HIDDEN
flag. When set, this flag enimport android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;public class HideTestActivity extends Activity implements OnClickListener{View main ; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); main = getLayoutInflater().from(this).inflate(R.layout.main, null); main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); main.setOnClickListener(this); setContentView(main); }@Overridepublic void onClick(View v) {int i = main.getSystemUiVisibility();if (i == View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) {main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);} else if (i == View.SYSTEM_UI_FLAG_VISIBLE){main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);} else if (i == View.SYSTEM_UI_FLAG_LOW_PROFILE) {main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);}}}
ables “low profile" mode for the system bar or navigation bar. Navigation buttons dim and other elements in the system bar also hide. Enabling this is useful for creating more immersive games without distraction for the system navigation buttons. - The
SYSTEM_UI_FLAG_VISIBLE
flag replaces theSTATUS_BAR_VISIBLE
flag to request the system bar or navigation bar be visible. - The
SYSTEM_UI_FLAG_HIDE_NAVIGATION
is a new flag that requests the navigation bar hide completely. Be aware that this works only for the navigation bar used by some handsets (it does not hide the system bar on tablets). The navigation bar returns to view as soon as the system receives user input. As such, this mode is useful primarily for video playback or other cases in which the whole screen is needed but user input is not required.
You can set each of these flags for the system bar and navigation bar by calling setSystemUiVisibility()
on any view in your activity. The window manager combines (OR-together) all flags from all views in your window and apply them to the system UI as long as your window has input focus. When your window loses input focus (the user navigates away from your app, or a dialog appears), your flags cease to have effect. Similarly, if you remove those views from the view hierarchy their flags no longer apply.
To synchronize other events in your activity with visibility changes to the system UI (for example, hide the action bar or other UI controls when the system UI hides), you should register a View.OnSystemUiVisibilityChangeListener
to be notified when the visibility of the system bar or navigation bar changes.
See the OverscanActivity class for a demonstration of different system UI options.
看完后,写个测试例子试一下,Ok~
- Android 4.0 隐藏虚拟按键(导航栏)的方法
- Android 4.0 隐藏虚拟按键(导航栏)的方法 .
- Android 4.0 隐藏虚拟按键(导航栏)的方法
- Android 4.0 隐藏虚拟按键(导航栏)的方法
- Android 4.0 隐藏虚拟按键(导航栏)的方法
- android 隐藏状态栏 导航栏 虚拟按键
- Android隐藏虚拟按键(底部导航栏)
- android ics打开/隐藏虚拟导航按键
- Android 隐藏状态栏和虚拟按键的通用方法
- 隐藏虚拟按键方法
- Android完全隐藏导航键/虚拟按键和状态栏
- android 隐藏虚拟按键
- Android5.0隐藏虚拟按键的方法
- 显示和隐藏虚拟按键的方法
- Android 监听系统虚拟导航栏按键
- 隐藏Android下的虚拟按键
- 隐藏Android底部的虚拟按键
- andriod 4.1 隐藏虚拟按键和导航栏
- 数理逻辑:命题逻辑(11)多值逻辑
- HTML特殊字符大全
- 给40亿个不重复的unsigned int的整数,没排过序的,然后再给一个数,如何快速判断这个数是否在那40亿个数当中?
- 数理逻辑:命题逻辑(12)命题逻辑总习题 (尚缺,待录)
- as3 下使用include,类似,c/c++用法;前面不用#号,demo
- Android 4.0 隐藏虚拟按键(导航栏)的方法 .
- tar命令的妙用
- 头文件中的#ifndef #define #endif 的使用
- DB2错误信息SQLCODE SQLSTATE (按sqlcode排序)
- 用Setup Factory 7.0制作安装程序
- Struts2拦截器的使用2
- iphone 4 摄像头前后切换
- 99个漂亮的注册和登录页面设计(附PSD)
- 迟来的真相:关于JavaScript的历史