`

android 隐藏虚拟按键

 
阅读更多
一 全部隐藏
可以试下
<uses-sdk android:minSdkVersion="15" />或者targetVersion=15
版本号可以对应你的手机的ROM的系统版本

二 部分隐藏

在VIEW对象上调用setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

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 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.

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.

import 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);  
    }  
  
    @Override  
    public 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);  
        }  
    }  
} 
分享到:
评论

相关推荐

    添加虚拟按键隐藏控制

    2. **隐藏虚拟按键**:在Android中,可以使用`WindowManager.LayoutParams`类来隐藏或显示虚拟按键。调用`getWindow().getDecorView()`获取到当前Activity的装饰视图,然后调用`setSystemUiVisibility()`方法,传入`...

    Android实现隐藏手机底部虚拟按键

    要隐藏虚拟按键,我们可以使用 Android 提供的系统UIFlag来实现。系统UIFlag是 Android 中的一个标志位,它可以用来控制系统的UI行为。我们可以使用 View 的 setSystemUiVisibility 方法来设置系统UIFlag,从而隐藏...

    Android 隐藏底部虚拟键的两种方法

    //隐藏虚拟按键,并且全屏 if (Build.VERSION.SDK_INT &gt; 11 && Build.VERSION.SDK_INT ) { // lower api View v = this.getWindow().getDecorView(); v.setSystemUiVisibility(View.GONE); } else if (Build....

    android 闪屏 欢迎界面 隐藏底部虚拟按钮全屏 适配方案

    - 在Activity的`onCreate()`方法中,获取到`Window`对象,并调用`setFlags()`方法,传递`SYSTEM_UI_FLAG_HIDE_NAVIGATION`标志,隐藏虚拟按键。 - 注意:隐藏后,用户可能无法快速返回主界面,因此需要监听`SYSTEM...

    RK系列 Android系统隐藏工具栏虚拟按键Jar包

    RK系列 Android系统隐藏工具栏虚拟按键Jar包

    Android隐藏手机底部虚拟按键的方法

    "Android隐藏手机底部虚拟按键的方法" Android 隐藏手机底部虚拟按键的方法是一种非常有用的技术,能够在我们的 Android 应用程序中隐藏底部虚拟按键,从而提供更加纯净的用户体验。下面我们将详细介绍这项技术,并...

    GMD自动隐藏虚拟按键专业版.zip

    【GMD自动隐藏虚拟按键专业版】是一款专为Android设备设计的应用程序,旨在提供更加纯净、无干扰的屏幕体验。该应用的主要功能是隐藏设备底部的系统导航栏,即我们通常所说的“虚拟按键”,如返回、主页和多任务键。...

    Android 中隐藏虚拟按键的方法实例代码

    本文将详细介绍如何在Android应用中实现隐藏虚拟按键的功能。 首先,我们需要了解API级别的差异,因为不同的Android版本处理隐藏虚拟按键的方式有所不同。从Android 3.0(API级别11)到4.4(API级别19),隐藏虚拟...

    Android 解决沉浸式状态栏和华为虚拟按键冲突

    通过以上策略,开发者可以有效地解决Android应用在华为设备上的沉浸式状态栏与虚拟按键冲突问题,提供一致且良好的用户体验。在开发过程中,不断学习和掌握Android系统的特性和设备差异,是提升应用质量的关键。

    自定义android虚拟键盘

    在Android系统中,虚拟键盘(通常称为输入法)是用户与设备交互的重要组成部分。自定义Android虚拟键盘允许开发者根据特定需求或应用场景定制键盘布局、功能和样式,为用户提供更个性化的输入体验。以下是对自定义...

    Android dialog 去除虚拟按键的解决方法

    这行代码将隐藏虚拟按键,使得 Activity 全屏显示。 方法二:在 Dialog 中去除虚拟按键 在 Dialog 中,我们可以使用以下代码来去除虚拟按键: ```java mDialog.getWindow().getDecorView().setSystemUiVisibility...

    ADB命令控制安卓手机(虚拟按键、状态栏)显示隐藏,或者直接禁用。

    4. 隐藏虚拟按键:虚拟按键,也称为导航栏,包括返回、主页和多任务按钮。使用以下命令可以隐藏虚拟按键: ``` adb shell input keyevent 82 ``` 这个命令模拟按下菜单键,从而隐藏虚拟按键。若要重新显示,...

    android 适配底部虚拟按键

    4. **自定义手势**:Android系统允许开发者通过`WindowInsetsController`或`ViewCompat.setOnApplyWindowInsetsListener()`接口,自定义手势来控制虚拟按键的显示和隐藏。这使得在特定场景下,如播放视频时,能更好...

    Delphi XE 10.2 FMX 程序中避免输入焦点被虚拟键盘遮挡

    在开发使用Delphi XE 10.2的FireMonkey (FMX) 应用程序时,遇到的一个常见问题是:当用户在Android设备上输入时,弹出的虚拟键盘可能会遮挡输入焦点所在的控件。这给用户体验带来不便,但通过理解和应用正确的技术,...

    Android监听输入法软键盘按键demo

    `InputMethodManager`是Android系统提供的管理输入法的类,可以用来控制软键盘的显示和隐藏。虽然它不直接提供按键监听,但我们可以通过监听IME(Input Method Editor)的动作事件来间接实现监听。通过重写`Activity...

    解决Android 虚拟按键遮住了页面内容的问题

    我们可以使用 `hideBottomUIMenu()` 方法来隐藏虚拟按键,并且实现全屏效果。该方法可以根据 Android 版本进行判断,以便在不同版本的 Android 系统中都能正常工作。 虚拟按键的原理 Android 虚拟按键是 Android ...

    安卓P 动态隐藏虚拟按键.zip

    在安卓P(Android P)系统中,动态隐藏虚拟按键是一项重要的功能优化,它允许开发者或者用户根据应用的需求或个人偏好来控制导航栏的可见性。这项功能主要涉及到系统的UI交互和自定义设置,提升了用户体验,特别是在...

Global site tag (gtag.js) - Google Analytics