隐藏虚拟导航

Android 4.0 因为项目需要, 要实现屏幕全屏,隐藏虚拟按键,即导航栏

在Android的API 中

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 the STATUS_BAR_HIDDEN flag. When set, this flag enables “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 the STATUS_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
SYSTEM_UI_FLAG_LOW_PROFILE 相当于隐藏导航栏
SYSTEM_UI_FLAG_VISIBLE 导航栏显示
SYSTEM_UI_FLAG_HIDE_NAVIGATION 要求导航栏完全隐藏–>但这对部分硬件设备有效

方法一:

public class MainActivity extends Activity {      Window window;      /** 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);         window = getWindow();          WindowManager.LayoutParams params = window.getAttributes();          params.systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE;          window.setAttributes(params);          setContentView(R.layout.main);      }  }  

方法二:

public class MainActivity extends Activity {      View main;      private Button btn;      /** 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);          btn = (Button) main.findViewById(R.id.btn);          btn.setOnClickListener(new OnClickListener() {              @Override              public void onClick(View v) {                  // TODO Auto-generated method stub                 int i = main.getSystemUiVisibility();                  if (i == View.SYSTEM_UI_FLAG_VISIBLE) {                      main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);                  }              }          });          setContentView(main);      }  

更多相关文章

  1. 隐藏Android下的虚拟按键
  2. Android状态栏和虚拟导航栏的适配总结
  3. Android(安卓)Memory Management, OutOfMemoryError
  4. Android(安卓)Launcher3 隐藏搜索框
  5. 〖Android〗简单隐藏Android虚拟键盘的方法
  6. What is Android?
  7. Activity去除标题栏和状态栏
  8. 最简单的android底部导航栏 + Fragment的实现方式
  9. Android(安卓)虚拟摇杆,多种模式回调,返回距离级别,方向,角度。

随机推荐

  1. Android(安卓)RxJava:一步步带你源码分析
  2. Android身份证件识别的OCR技术SDK
  3. Android(安卓)项目编译过程
  4. APPS大乱斗:4大Android文件浏览器横评(一)
  5. 在Ubuntu上下载、编译和安装Android最新
  6. android常用调试工具fiddle、wireshark和
  7. Android(安卓)PK ios,是谁胜谁负
  8. 【Android(安卓)多语言切换简单实例分享
  9. Android周学习Step By Step(4)--界面布局
  10. Android(安卓)cardview覆盖问题