永久隐藏 Android 状态栏
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21371802/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Permanently hide Android Status Bar
提问by dtyler
I'm trying to hide the system Status Bar on an Android 4.4 device. This is for a kiosk-mode where my app will be the only app ever run on the device. The target device for now is a 2013 Nexus 7.
我正在尝试在 Android 4.4 设备上隐藏系统状态栏。这适用于自助服务终端模式,在这种模式下,我的应用将是设备上唯一运行的应用。目前的目标设备是 2013 Nexus 7。
The device is rooted, and I've been able to completely remove the bottom Navigation Bar with some info from this post.
该设备已植根,我已经能够完全删除底部导航栏和这篇文章中的一些信息。
For the top Status Bar, everything I have tried only hides the bar temporarily. If my users motion down at the top of the screen, the status bar reappears. I don't want to allow them to see the time, get to settings or even see notifications.
对于顶部状态栏,我尝试过的一切只是暂时隐藏了状态栏。如果我的用户在屏幕顶部向下移动,状态栏会重新出现。我不想让他们看到时间、进入设置甚至看到通知。
Posts I've found and already tried:
我发现并已经尝试过的帖子:
- Hide System Bar in Tablets
- Permanently hide navigation bar on activity
- Hide status bar on android
- Disable/Hide status bar in Android
Any suggestions?
有什么建议?
Ideally, I'd love to be able to edit build.prop to do this, since I'm already doing that for the navigation bar, and could do this at the same time. I'm trying to not have to build my own android image.
理想情况下,我希望能够编辑 build.prop 来执行此操作,因为我已经在为导航栏执行此操作,并且可以同时执行此操作。我正在尝试不必构建自己的 android 映像。
Update:
更新:
After some more work, this seems to depend somewhat on the exact build of android, or the device its running on.
经过一些更多的工作,这似乎在某种程度上取决于 android 的确切构建,或其运行的设备。
Some devices, such as the Nexus series I've been working with allow the user to swipe to make the bar reappear.
某些设备,例如我一直在使用的 Nexus 系列,允许用户滑动以使栏重新出现。
However, I've recently tried this on a Verizon Eclipse, and the bar does not reappear, which is what I was looking for.
但是,我最近在 Verizon Eclipse 上尝试了此操作,并且该栏没有重新出现,这正是我想要的。
I'm still looking for a better solution to target all devices, but it will probably come down to creating my own build of android.
我仍在寻找针对所有设备的更好解决方案,但它可能会归结为创建我自己的 android 版本。
回答by Abhimaan
We could not prevent the status appearing in full screen mode in kitkat devices, so made a hack which still suits the requirement ie block the status bar from expanding.
我们无法阻止在 kitkat 设备中以全屏模式显示状态,所以做了一个仍然符合要求的 hack,即阻止状态栏扩展。
For that to work, the app was not made full screen. We put a overlay over status bar and consumed all input events. It prevented the status from expanding.
为此,该应用程序并未全屏显示。我们在状态栏上放置了一个覆盖层并消耗了所有输入事件。它阻止了地位的扩大。
note:
笔记:
- customViewGroup is custom class which extends any layout(frame,relative layout etc) and consumes touch event.
- to consume touch event override the onInterceptTouchEvent method of the view group and return true
- customViewGroup 是自定义类,它扩展任何布局(框架、相对布局等)并使用触摸事件。
- 消费触摸事件覆盖视图组的onInterceptTouchEvent方法并返回true
Updated
更新
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
customViewGroup implementationCode :
WindowManager manager = ((WindowManager) getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE));
WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
localLayoutParams.gravity = Gravity.TOP;
localLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
// this is to enable the notification to recieve touch events
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
// Draws over status bar
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
localLayoutParams.height = (int) (50 * getResources()
.getDisplayMetrics().scaledDensity);
localLayoutParams.format = PixelFormat.TRANSPARENT;
customViewGroup view = new customViewGroup(this);
manager.addView(view, localLayoutParams);
Hope this helps you
希望这对你有帮助
回答by D. Gibbs
I know this is an old question but hopefully it will help someone. Here are two very simple calls to disable and enable the status bar that I have used before. Can be used from the command line or executed by a Java app:
我知道这是一个老问题,但希望它会帮助某人。这里有两个非常简单的调用来禁用和启用我之前使用过的状态栏。可以从命令行使用或由 Java 应用程序执行:
Disable:
禁用:
service call activity 42 s16 com.android.systemui
Enable:
使能够:
am startservice -n com.android.systemui/.SystemUIService
回答by dtyler
I did try the workaround provided by @gonglong, but I wasn't happy with the result because of a flash in the UI as the workaround kicked in.
我确实尝试了@gonglong 提供的解决方法,但我对结果并不满意,因为该解决方法开始时 UI 中出现了闪光。
Instead, I was able to do this as root:
相反,我能够以 root 身份执行此操作:
settings put secure user_setup_complete 0
I think on a normal device, this would cause the initial device setup to start, but on my devices, I've removed that APK from system so that doesn't happen.
我认为在普通设备上,这会导致初始设备设置开始,但在我的设备上,我已从系统中删除了该 APK,因此不会发生这种情况。
This isn't documented anywhere I can find, but has a nice effect, where the top settings UI can't be dragged down. The notifications area can still be dragged down.
这在我能找到的任何地方都没有记录,但有一个很好的效果,顶部设置 UI 不能被拖下。通知区域仍然可以向下拖动。
Another setting that I found useful was:
我发现有用的另一个设置是:
settings put global device_provisioned 0
This hides the Airplane Mode and Silent Mode options from the Power menu, which is an added bonus for my application.
这隐藏了电源菜单中的飞行模式和静音模式选项,这对我的应用程序来说是一个额外的好处。
There might be more side effects, but I've yet to find any that matter to me.
可能会有更多的副作用,但我还没有发现任何对我来说很重要的副作用。
Full List
完整列表
This list was taken from a Nexus 7 2013 LTE running brand new Android 4.4.3 (KTU84L). The number in square brackets is the value when I pulled the db file, which was after basic setup device setup and enabling developer/USB, but before making any other changes in settings
此列表取自运行全新 Android 4.4.3 (KTU84L) 的 Nexus 7 2013 LTE。方括号中的数字是我拉 db 文件时的值,这是在基本设置设备设置和启用开发人员/USB 之后,但在对设置进行任何其他更改之前
This file was found at data/data/com.android.providers.settings/databases/settings.db
这个文件是在 data/data/com.android.providers.settings/databases/settings.db
Note: Some URLS required adding an extra space character to bypass SO filters
注意:某些 URL 需要添加额外的空格字符以绕过 SO 过滤器
system
namespace
system
命名空间
- volume_music [11]
- volume_ring [5]
- volume_system [7]
- volume_voice [4]
- volume_alarm [6]
- volume_notification [5]
- volume_bluetooth_sco [7]
- mode_ringer_streams_affected [174]
- mute_streams_affected [46]
- vibrate_when_ringing [0]
- dim_screen [1]
- dtmf_tone_type [0]
- hearing_aid [0]
- tty_mode [0]
- screen_brightness [87]
- screen_brightness_mode [1]
- window_animation_scale [1.0]
- transition_animation_scale [1.0]
- accelerometer_rotation [1]
- haptic_feedback_enabled [1]
- notification_light_pulse [1]
- dtmf_tone [1]
- sound_effects_enabled [1]
- lockscreen_sounds_enabled [1]
- pointer_speed [0]
- alarm_alert [content://media/internal/audio/media/11]
- notification_sound [content://media/internal/audio/media/27]
- ringtone [content://media/internal/audio/media/35]
- next_alarm_formatted []
- radio.data.stall.recovery.action [0]
- screen_off_timeout [30000]
- 音量音乐 [11]
- volume_ring [5]
- volume_system [7]
- volume_voice [4]
- 音量警报 [6]
- volume_notification [5]
- volume_bluetooth_sco [7]
- mode_ringer_streams_affected [174]
- mute_streams_affected [46]
- vibrate_when_ringing [0]
- dim_screen [1]
- dtmf_tone_type [0]
- 助听器 [0]
- tty_mode [0]
- 屏幕亮度 [87]
- screen_brightness_mode [1]
- window_animation_scale [1.0]
- transition_animation_scale [1.0]
- 加速度计_旋转 [1]
- haptic_feedback_enabled [1]
- 通知光脉冲 [1]
- dtmf_tone [1]
- sound_effects_enabled [1]
- lockscreen_sounds_enabled [1]
- 指针速度 [0]
- alarm_alert [content://media/internal/audio/media/11]
- notification_sound [content://media/internal/audio/media/27]
- 铃声 [content://media/internal/audio/media/35]
- next_alarm_formatted []
- radio.data.stall.recovery.action [0]
- screen_off_timeout [30000]
global
namespace
global
命名空间
- airplane_mode_on [0]
- airplane_mode_radios [cell,bluetooth,wifi,nfc,wimax]
- airplane_mode_toggleable_radios [bluetooth,wifi,nfc]
- auto_time [1]
- auto_time_zone [1]
- stay_on_while_plugged_in [0]
- wifi_sleep_policy [2]
- mode_ringer [2]
- package_verifier_enable [1]
- wifi_networks_available_notification_on [1]
- bluetooth_on [0]
- cdma_cell_broadcast_sms [1]
- data_roaming [0]
- mobile_data [1]
- netstats_enabled [1]
- install_non_market_apps [0]
- usb_mass_storage_enabled [1]
- wifi_max_dhcp_retry_count [9]
- wifi_display_on [0]
- lock_sound [/system/media/audio/ui/Lock.ogg]
- unlock_sound [/system/media/audio/ui/Unlock.ogg]
- power_sounds_enabled [1]
- low_battery_sound [/system/media/audio/ui/LowBattery.ogg]
- dock_sounds_enabled [0]
- desk_dock_sound [/system/media/audio/ui/Dock.ogg]
- desk_undock_sound [/system/media/audio/ui/Undock.ogg]
- car_dock_sound [/system/media/audio/ui/Dock.ogg]
- car_undock_sound [/system/media/audio/ui/Undock.ogg]
- wireless_charging_started_sound [/system/media/audio/ui/WirelessChargingStarted.ogg]
- dock_audio_media_enabled [1]
- set_install_location [0]
- default_install_location [0]
- emergency_tone [0]
- call_auto_retry [0]
- preferred_network_mode [9]
- subscription_mode [1]
- low_battery_sound_timeout [3600000]
- wifi_watchdog_on [1]
- audio_safe_volume_state [1]
- send_action_app_error [1]
- web_autofill_query_url [http:// android.clients.google.com/proxy/webautofill]
- sms_short_codes_content_url [http://www.gstatic.com/android/config_update/07172013-sms-blacklist.txt]
- sms_short_codes_metadata_url [http://www.gstatic.com/android/config_update/07172013-sms-metadata.txt]
- cert_pin_metadata_url [http://www.gstatic.com/android/config_update/10142013-metadata.txt]
- cert_pin_content_url [http://www.gstatic.com/android/config_update/10142013-pins.txt]
- wifi_on [1]
- assisted_gps_enabled [1]
- wifi_scan_always_enabled [1]
- device_provisioned [1]
- bugreport_in_power_menu [0]
- development_settings_enabled [1]
- adb_enabled [1]
- wifi_country_code [us]
- 飞机模式开启 [0]
- plane_mode_radios [手机、蓝牙、wifi、nfc、wimax]
- plane_mode_toggleable_radios [蓝牙、wifi、nfc]
- 自动时间 [1]
- auto_time_zone [1]
- stay_on_while_plugged_in [0]
- wifi_sleep_policy [2]
- mode_ringer [2]
- package_verifier_enable [1]
- wifi_networks_available_notification_on [1]
- bluetooth_on [0]
- cdma_cell_broadcast_sms [1]
- 数据漫游 [0]
- 移动数据 [1]
- netstats_enabled [1]
- install_non_market_apps [0]
- usb_mass_storage_enabled [1]
- wifi_max_dhcp_retry_count [9]
- wifi_display_on [0]
- lock_sound [/system/media/audio/ui/Lock.ogg]
- unlock_sound [/system/media/audio/ui/Unlock.ogg]
- power_sounds_enabled [1]
- low_battery_sound [/system/media/audio/ui/LowBattery.ogg]
- Dock_sounds_enabled [0]
- Desk_dock_sound [/system/media/audio/ui/Dock.ogg]
- Desk_undock_sound [/system/media/audio/ui/Undock.ogg]
- car_dock_sound [/system/media/audio/ui/Dock.ogg]
- car_undock_sound [/system/media/audio/ui/Undock.ogg]
- wireless_charge_started_sound [/system/media/audio/ui/WirelessChargingStarted.ogg]
- Dock_audio_media_enabled [1]
- set_install_location [0]
- default_install_location [0]
- 紧急情况[0]
- call_auto_retry [0]
- 优选网络模式 [9]
- 订阅模式 [1]
- low_battery_sound_timeout [3600000]
- wifi_watchdog_on [1]
- audio_safe_volume_state [1]
- send_action_app_error [1]
- web_autofill_query_url [http://android.clients.google.com/proxy/webautofill]
- sms_short_codes_content_url [ http://www.gstatic.com/android/config_update/07172013-sms-blacklist.txt]
- sms_short_codes_metadata_url [ http://www.gstatic.com/android/config_update/07172013-sms-metadata.txt]
- cert_pin_metadata_url [ http://www.gstatic.com/android/config_update/10142013-metadata.txt]
- cert_pin_content_url [ http://www.gstatic.com/android/config_update/10142013-pins.txt]
- wifi_on [1]
- 已启用辅助 GPS [1]
- wifi_scan_always_enabled [1]
- device_provisioned [1]
- bugreport_in_power_menu [0]
- development_settings_enabled [1]
- adb_enabled [1]
- wifi_country_code [我们]
secure
namespace
secure
命名空间
- wifi_watchdog_watch_list [GoogleGuest]
- mock_location [0]
- backup_enabled [0]
- backup_transport [com.google.android.backup/.BackupTransportService]
- mount_play_not_snd [1]
- mount_ums_autostart [0]
- mount_ums_prompt [1]
- mount_ums_notify_enabled [1]
- accessibility_script_injection [0]
- accessibility_web_content_key_bindings [0x13=0x01000100; 0x14=0x01010100; 0x15=0x02000001; 0x16=0x02010001; 0x200000013=0x02000601; 0x200000014=0x02010601; 0x200000015=0x03020101; 0x200000016=0x03010201; 0x200000023=0x02000301; 0x200000024=0x02010301; 0x200000037=0x03070201; 0x200000038=0x03000701:0x03010701:0x03020701;]
- long_press_timeout [500]
- touch_exploration_enabled [0]
- speak_password [0]
- accessibility_script_injection_url [https://ssl.gstatic.com/accessibility/javascript/android/AndroidVox_v1.js]
- lockscreen.disabled [0]
- screensaver_enabled [1]
- screensaver_activate_on_dock [1]
- screensaver_activate_on_sleep [0]
- screensaver_components [com.google.android.deskclock/com.android.deskclock.Screensaver]
- screensaver_default_component [com.google.android.deskclock/com.android.deskclock.Screensaver]
- accessibility_display_magnification_enabled [0]
- accessibility_display_magnification_scale [2.0]
- accessibility_display_magnification_auto_update [1]
- android_id [a0ef8b2a9ade982c]
- enabled_input_methods [com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME:com.google.android.googlequicksearchbox/com.google.android.voicesearch.ime.VoiceInputMethodService]
- input_methods_subtype_history []
- selected_input_method_subtype [-1]
- selected_spell_checker [com.google.android.inputmethod.latin/com.android.inputmethod.latin.spellcheck.AndroidSpellCheckerService]
- selected_spell_checker_subtype [0]
- lock_screen_owner_info_enabled [0]
- voice_recognition_service [com.google.android.googlequicksearchbox/com.google.android.voicesearch.serviceapi.GoogleRecognitionService]
- default_input_method [com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME]
- enabled_print_services [com.google.android.apps.cloudprint/com.google.android.apps.cloudprint.printdialog.services.CloudPrintService:com.hp.android.printservice/com.hp.android.printservice.ServiceAndroidPrint]
- enabled_on_first_boot_system_print_services [com.google.android.apps.cloudprint/com.google.android.apps.cloudprint.printdialog.services.CloudPrintService:com.hp.android.printservice/com.hp.android.printservice.ServiceAndroidPrint]
- bluetooth_name [Nexus 7]
- masterLocationPackagePrefixBlacklist [com.google.,com.semaphoremobile.zagat.android]
- serial_blacklist [827,864]
- dropbox:data_app_anr [disabled]
- dropbox:data_app_wtf [disabled]
- ssl_session_cache [file]
- pubkey_blacklist [5f3ab33d55007054bc5e3e5553cd8d8465d77c61,783333c9687df63377efceddd82efa9101913e8e]
- facelock_liveliness_recognition_threshold [2.2]
- facelock_detection_threshold [0.0]
- dropbox:data_app_crash [disabled]
- masterLocationPackagePrefixWhitelist [com.google.android.gms]
- lockscreen.options [enable_facelock]
- facelock_max_center_movement [10.0]
- bluetooth_address [AC:22:0B:A5:AF:3D]
- bluetooth_addr_valid [1]
- config_update_certificate [ truncated base64 content]
- location_providers_allowed [gps,network]
- allowed_geolocation_origins [http://www.google.co.ukhttp:// www.google.com]
- locationPackagePrefixBlacklist []
- user_setup_complete [1]
- locationPackagePrefixWhitelist []
- last_setup_shown [eclair_1]
- wifi_watchdog_watch_list [GoogleGuest]
- 模拟位置 [0]
- 备份启用 [0]
- backup_transport [com.google.android.backup/.BackupTransportService]
- mount_play_not_snd [1]
- mount_ums_autostart [0]
- mount_ums_prompt [1]
- mount_ums_notify_enabled [1]
- 可访问性_脚本_注入 [0]
- Accessibility_web_content_key_bindings [0x13=0x01000100; 0x14=0x01010100;0x15=0x02000001;0x16=0x02010001;0x200000013=0x02000601;0x200000014=0x02010601;0x200000015=0x03020101;0x200000016=0x03010201;0x200000023=0x02000301;0x200000024=0x02010301;0x200000037=0x03070201;0x200000038=0x03000701:0x03010701:0x03020701;]
- long_press_timeout [500]
- touch_exploration_enabled [0]
- 说话密码 [0]
- accessibility_script_injection_url [ https://ssl.gstatic.com/accessibility/javascript/android/AndroidVox_v1.js]
- lockscreen.disabled [0]
- 启用屏幕保护程序 [1]
- screenaver_activate_on_dock [1]
- screenaver_activate_on_sleep [0]
- screenaver_components [com.google.android.deskclock/com.android.deskclock.Screensaver]
- screenaver_default_component [com.google.android.deskclock/com.android.deskclock.Screensaver]
- Accessibility_display_magnification_enabled [0]
- 可访问性_display_magnification_scale [2.0]
- Accessibility_display_magnification_auto_update [1]
- android_id [a0ef8b2a9ade982c]
- enabled_input_methods [com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME:com.google.android.googlequicksearchbox/com.google.android.voicesearch.ime.VoiceInputMethodService]
- input_methods_subtype_history []
- selected_input_method_subtype [-1]
- selected_spell_checker [com.google.android.inputmethod.latin/com.android.inputmethod.latin.spellcheck.AndroidSpellCheckerService]
- selected_spell_checker_subtype [0]
- lock_screen_owner_info_enabled [0]
- voice_recognition_service [com.google.android.googlequicksearchbox/com.google.android.voicesearch.serviceapi.GoogleRecognitionService]
- default_input_method [com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME]
- enabled_print_services [com.google.android.apps.cloudprint/com.google.android.apps.cloudprint.printdialog.services.CloudPrintService:com.hp.android.printservice/com.hp.android.printservice.ServiceAndroidPrint]
- enabled_on_first_boot_system_print_services [com.google.android.apps.cloudprint/com.google.android.apps.cloudprint.printdialog.services.CloudPrintService:com.hp.android.printservice/com.hp.android.printservice.ServiceAndroidPrint]
- 蓝牙名称 [Nexus 7]
- masterLocationPackagePrefixBlacklist [com.google.,com.semaphoremobile.zagat.android]
- serial_blacklist [827,864]
- dropbox:data_app_anr [已禁用]
- dropbox:data_app_wtf [已禁用]
- ssl_session_cache [文件]
- pubkey_blacklist [5f3ab33d55007054bc5e3e5553cd8d8465d77c61,783333c9687df63377efceddd82efa9101913e8e]
- facelock_liveliness_recognition_threshold [2.2]
- facelock_detection_threshold [0.0]
- dropbox:data_app_crash [已禁用]
- masterLocationPackagePrefixWhitelist [com.google.android.gms]
- lockscreen.options [enable_facelock]
- facelock_max_center_movement [10.0]
- bluetooth_address [AC:22:0B:A5:AF:3D]
- bluetooth_addr_valid [1]
- config_update_certificate [截断的 base64 内容]
- location_providers_allowed [gps,network]
- allowed_geolocation_origins [ http://www.google.co.uk http://www.google.com]
- locationPackagePrefixBlacklist []
- user_setup_complete [1]
- locationPackagePrefixWhitelist []
- last_setup_shown [eclair_1]
回答by AvielNiego
I've used this answer to hide the softkeys: https://stackoverflow.com/a/27003890/1525867
我用这个答案来隐藏软键:https: //stackoverflow.com/a/27003890/1525867
And for disabling the StatusBar (this may harm your device so do it carfully. I've ruined my device several times before I managed to do it) Tested on Asus Tinker Board, Android 6:
对于禁用状态栏(这可能会损坏您的设备,所以请小心操作。在我设法做到之前,我已经损坏了我的设备好几次)在 Asus Tinker Board,Android 6 上测试:
- Download apktool from here https://bitbucket.org/iBotPeaches/apktool/downloads/and add it to
path
in your favorite way pull
SystemUI.apk
from your device:adb pull /system/priv-app/SystemUI/SystemUI.apk
the path toSystemUI.apk
may be differentpull
framework-res.apk
from your deviceadb pull /system/framework/framework-res.apk
the path toframework-res.apk
may be differentrun
apktool if framework-res.apk
run
apktool if SystemUI.apk
run
apktool d SystemUI.apk
Open
SystemUI\res\layout\status_bar.xml
and addandroid:visibility="gone"
to the top most xml element (for me it wascom.android.systemui.statusbar.phone.PhoneStatusBarView
)run
apktool b SystemUI
Go to
SystemUI\original
and copyAndroidManifest.xml
andMETA-INF
toSystemUI\build\apk\
run
apktool b SystemUI
againGo to
SystemUI\dist\
and override the device's originalSystemUI.apk
with the one atSystemUI\dist\SystemUI.apk
withadb push SystemUI\dist\SystemUI.apk /system/priv-app/SystemUI/SystemUI.apk
Restart device
- 从这里下载 apktool https://bitbucket.org/iBotPeaches/apktool/downloads/并以
path
您喜欢的方式添加到 SystemUI.apk
从您的设备中拉出:adb pull /system/priv-app/SystemUI/SystemUI.apk
路径SystemUI.apk
可能不同framework-res.apk
从您的设备中拉出adb pull /system/framework/framework-res.apk
的路径framework-res.apk
可能不同跑
apktool if framework-res.apk
跑
apktool if SystemUI.apk
跑
apktool d SystemUI.apk
打开
SystemUI\res\layout\status_bar.xml
并添加android:visibility="gone"
到最顶部的 xml 元素(对我来说是com.android.systemui.statusbar.phone.PhoneStatusBarView
)跑
apktool b SystemUI
转到
SystemUI\original
并复制AndroidManifest.xml
并META-INF
到SystemUI\build\apk\
apktool b SystemUI
再次运行进入
SystemUI\dist\
和覆盖设备的原始SystemUI.apk
与一个在SystemUI\dist\SystemUI.apk
用adb push SystemUI\dist\SystemUI.apk /system/priv-app/SystemUI/SystemUI.apk
重启设备
Based on this thread https://forum.xda-developers.com/showthread.php?t=2203166
基于此线程https://forum.xda-developers.com/showthread.php?t=2203166
回答by Muhammed Refaat
A great solution I found for that issue, setting each Activity theme
& windowSoftInputMode
to the following values :
我为该问题找到了一个很好的解决方案,将每个 Activity theme
&windowSoftInputMode
设置为以下值:
<activity android:name=".MyActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="adjustResize"> <!-- theme : to set the activity to a full screen mode without a status bar(like in some games) -->
</activity> <!-- windowSoftInputMode : to resize the activity so that it fits the condition of displaying a softkeyboard -->
for more info refer here.
有关更多信息,请参阅此处。
回答by gonglong
I don't have a perfect solution but a workaround here. The basic idea is to listen the system ui status changes and force navigation/status bar as invisible. It takes effect as similar as setting IMMERSIVE_STICKY mode but disappearing navigation/status bar quicker than IMMERSIVE_STICKY.
我没有完美的解决方案,但这里有一个解决方法。基本思想是监听系统 ui 状态变化并强制导航/状态栏不可见。它的作用类似于设置 IMMERSIVE_STICKY 模式,但比 IMMERSIVE_STICKY 更快地消失导航/状态栏。
here it is:
这里是:
set system ui style in onCreate() and on onResume function, and set system ui change listener
在 onCreate() 和 onResume 函数中设置系统 ui 样式,并设置系统 ui 更改侦听器
mDecroView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE);
mDecroView.setOnSystemUiVisibilityChangeListener(this);
force system bar as invisible in onSystemUiVisibilityChange, setting system ui some seconds later otherwise it would take on effect(does not know exactly why, maybe system just ignores the system ui setting request when system bar showing not yet completed)
强制系统栏在 onSystemUiVisibilityChange 中不可见,设置系统 ui 几秒钟后,否则它会生效(不知道确切原因,也许系统只是在系统栏显示尚未完成时忽略系统 ui 设置请求)
public void onSystemUiVisibilityChange(int visibility) {
// TODO Auto-generated method stub
Log.d(TAG, "onSystemUiVisibilityChange called with visibility " + visibility);
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0){
if(null == mHandler){
mHandler = new MyHandler();
}
if(null != mHandler){
mHandler.removeMessages(MSG_HIDE_SYSTEM_BAR);
mHandler.sendEmptyMessageDelayed(MSG_HIDE_SYSTEM_BAR, 50);
}
//the deccro view is not in full screen
Log.d(TAG, "setSystemUiVisibility");
Log.d(TAG, "current system ui is " + mDecroView.getSystemUiVisibility());
}
}
then you can set system ui like this:
然后你可以像这样设置系统用户界面:
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
super.handleMessage(msg);
switch(msg.what){
case MSG_HIDE_SYSTEM_BAR:
mDecroView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE);
break;
}
}
回答by mojtaba.khalafi7
try this code:
试试这个代码:
disable statusbar and navbar
禁用状态栏和导航栏
adb shell
su
pm disable com.android.systemui
reboot
enable statusbar and navbar
启用状态栏和导航栏
adb shell
su
pm enable com.android.systemui
reboot
It works on Android 5.1.1 but the usb camera is down
它适用于 Android 5.1.1,但 USB 摄像头已关闭
Another way (my device worked without any problems)
另一种方式(我的设备没有任何问题)
Remove System Navigation Bar ? The Android System Navigation Bar is the bar at the bottom of the screen which presents the back, home, and app-switch soft-keys.
删除系统导航栏?Android 系统导航栏是屏幕底部的栏,显示返回、主页和应用程序切换软键。
As the system navigation bar is independent from any installed Android application in particular, removing it is done in the Android OS.
由于系统导航栏独立于任何已安装的 Android 应用程序,因此删除它是在 Android 操作系统中完成的。
To accomplish this on a rooted installed device you can set the qemu.hw.mainkeys property to 1 by editing /system/build.prop:
要在有根安装的设备上完成此操作,您可以通过编辑 /system/build.prop 将 qemu.hw.mainkeys 属性设置为 1:
qemu.hw.mainkeys=1
To accomplish this at build time you would set the 'config_showNavigationBar' value to false in your device overlay (ie device/gateworks/ventana/overlay/frameworks/base/core/res/res/values/config.xml):
要在构建时完成此操作,您需要在设备叠加层(即 device/gateworks/ventana/overlay/frameworks/base/core/res/res/values/config.xml)中将 'config_showNavigationBar' 值设置为 false:
<bool name="config_showNavigationBar">false</bool>
Note you could also make build.prop modifications at build time by adding to the PRODUCT_DEFAULT_PROPERTY_OVERRIDES or ADDITIONAL_BUILD_PROPERTIES variables which can be found in your device target configuration (ie imx6.mk and BoardConfig.mk in device/gateworks/ventana/).
请注意,您还可以在构建时通过添加到 PRODUCT_DEFAULT_PROPERTY_OVERRIDES 或 ADDITIONAL_BUILD_PROPERTIES 变量来修改 build.prop,这些变量可以在您的设备目标配置中找到(即设备/gateworks/ventana/ 中的 imx6.mk 和 BoardConfig.mk)。
Additionally, you can hide the navigation bar (and status bar) within an application by setting the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag however it will pop back if the user touches anywhere on the screen. http://trac.gateworks.com/wiki/Android/Kiosk
此外,您可以通过设置 SYSTEM_UI_FLAG_HIDE_NAVIGATION 标志来隐藏应用程序中的导航栏(和状态栏),但是如果用户触摸屏幕上的任何位置,它就会弹出。 http://trac.gateworks.com/wiki/Android/Kiosk
回答by DiegoAlt
add this before : setContentView(R.layout.x);
在此之前添加: setContentView(R.layout.x);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes title bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.x);