Android 隐藏平板电脑系统栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11958034/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:18:01  来源:igfitidea点击:

Hide Tablet system bar

androidandroid-3.0-honeycombtabletstatusbar

提问by Chirag Patel

I want to hide system bar for tablet device. I searched a lot but not succeed. I added image for it.

我想隐藏平板设备的系统栏。我搜索了很多但没有成功。我为它添加了图像。

I found some solution like

我找到了一些解决方案

View v = findViewById(R.id.view_id);
v.setSystemUiVisibility(View.STATUS_BAR_HIDDEN); 

but I dont know how to use it enter image description here

但我不知道如何使用它 在此处输入图片说明

And I know that is possible as http://forum.xda-developers.com/showthread.php?t=1228046Can any one know how to do this ?

而且我知道这是可能的,因为http://forum.xda-developers.com/showthread.php?t=1228046谁能知道如何做到这一点?

采纳答案by Chirag Patel

Finally after searching lots of time I got some alternativ for my requirement.

最后在搜索了很多时间后,我得到了一些满足我要求的替代方案。

I know this is not a good idea for a programmer to back off from this situation but for my time limit I used this way...

我知道这对于程序员来说从这种情况中退缩不是一个好主意,但是对于我的时间限制,我使用了这种方式......

I found this link and application which fullfil my requirement

我发现这个链接和应用程序满足了我的要求

http://www.42gears.com/blog/2012/04/how-to-hide-bottom-bar-in-rooted-android-3-0-tablets-using-surelock/

http://www.42gears.com/blog/2012/04/how-to-hide-bottom-bar-in-rooted-android-3-0-tablets-using-surelock/

please visit this once if you want this type of requirement in your application ....

如果您希望在您的应用程序中满足这种类型的要求,请访问一次....

Thanks to all for helping me in my problem...

感谢大家帮助我解决我的问题...

回答by Basher51

Code snippet to show/hide status bar on rooted android tablets

在有根的 Android 平板电脑上显示/隐藏状态栏的代码片段

To hide:

隐藏:



            Process proc = null;

            String ProcID = "79"; //HONEYCOMB AND OLDER

            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH){
                ProcID = "42"; //ICS AND NEWER
            }

            try {
                proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "service call activity "+ProcID+" s16 com.android.systemui" });
            } catch (Exception e) {
                Log.w("Main","Failed to kill task bar (1).");
                e.printStackTrace();
            }
            try {
                proc.waitFor();
            } catch (Exception e) {
                Log.w("Main","Failed to kill task bar (2).");
                e.printStackTrace();
            }

To show:

显示:



            Process proc = null;
            try {
                proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "am startservice -n com.android.systemui/.SystemUIService" });
            } catch (Exception e) {
                Log.w("Main","Failed to kill task bar (1).");
                e.printStackTrace();
            }
            try {
                proc.waitFor();
            } catch (Exception e) {
                Log.w("Main","Failed to kill task bar (2).");
                e.printStackTrace();
            }

回答by Andi Jay

It is not possible to hide the system bar. There is nothing in the API that allows for it. This is because the user always needs access to the home and back keys in case the app freezes or does something goofy where the user just needs to get out of the app. You can only hide the action bar.

无法隐藏系统栏。API 中没有任何内容允许这样做。这是因为用户总是需要访问 home 键和 back 键,以防应用程序冻结或在用户只需要退出应用程序的情况下做了一些愚蠢的事情。您只能隐藏操作栏。

回答by M P Mathugama

There is a workaround to disable menu bar in all most all tablets without rooting. But this is bit tricky, but it works clean. Several well known apps in the market at the moment using this strategy to achieve this disable menu bar feature for their apps.

有一种解决方法可以在所有平板电脑中禁用菜单栏而无需生根。但这有点棘手,但它很干净。目前市场上的几个知名应用程序都使用这种策略来实现其应用程序的禁用菜单栏功能。

  • Grant admin privilege.
  • Set password & lock the device using device admin profile api
  • Then load what ever the UIs on top of the native lock screen. (Of course this will show background lock screen whenever a transition happens between activities. But if logic is organized well, then it will be smooth & less noticed by the user)
  • When need to enable back, reset password to "" using resetPassword("", 0) of device policy manager object.
  • 授予管理员权限。
  • 使用设备管理员配置文件 api 设置密码并锁定设备
  • 然后在本机锁定屏幕顶部加载任何 UI。(当然,每当活动之间发生转换时,这都会显示背景锁定屏幕。但是如果逻辑组织得很好,那么它会很流畅并且不会被用户注意到)
  • 当需要启用返回时,使用设备策略管理器对象的 resetPassword("", 0) 将密码重置为 ""。

回答by Sahal Zaman

var width = innerWidth;

var height = innerHeight;

I think this code will help for you.its not hide the tablet bar but your application fit on any device you can use this (I used this code in javascript for cord ova mobile application)

我认为这段代码对你有帮助。它不会隐藏平板电脑栏,但你的应用程序适合你可以使用它的任何设备(我在 javascript 中使用了这段代码用于cord ova移动应用程序)

回答by user2626972

You just need combination of SYSTEM_UI_FLAG_IMMERSIVE_STICKY | SYSTEM_UI_FLAG_HIDE_NAVIGATION | SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN. For example, if you use opengl and glSurfaceView is you surface:

你只需要 SYSTEM_UI_FLAG_IMMERSIVE_STICKY | 的组合 SYSTEM_UI_FLAG_HIDE_NAVIGATION | SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN。例如,如果您使用 opengl 和 glSurfaceView 是您的表面:

glSurfaceView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
                View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

Swipe at bottom to see the bottom bar, it will hide again after few seconds.

在底部滑动以查看底部栏,几秒钟后它会再次隐藏。

回答by PiyushMishra

You can't hide it but you can simply disable it, except home. Try this link.. Using SYSTEM_UI_FLAG_LOW_PROFILE you can dim your system bar and using onWindowFocusChanged()can take the focus and collapse it.

你不能隐藏它,但你可以简单地禁用它,除了家。试试这个链接。. 使用 SYSTEM_UI_FLAG_LOW_PROFILE 您可以使系统栏变暗,使用onWindowFocusChanged()可以获取焦点并将其折叠。

回答by Nate-Wilkins

I believe its the same for all android devices.

我相信它对所有 android 设备都是一样的。

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                     WindowManager.LayoutParams.FLAG_FULLSCREEN);

I also found another solution but this of course is just a separate app called surelock.

我还找到了另一个解决方案,但这当然只是一个名为surelock的单独应用程序。

http://onkarsingh.sys-con.com/node/2184158

http://onkarsingh.sys-con.com/node/2184158

EDIT:

编辑:

The above code doesn't hide the Tablet Bar. I'll leave my answer up for those looking to hide the System Bar in another Android Device.

上面的代码不会隐藏 Tablet Bar。对于那些希望在另一个 Android 设备中隐藏系统栏的人,我会留下我的答案。

回答by Philippe T.

I found a trick on a galaxy tab for use it as a kiosk according to the developer guide of Samsung

根据三星开发人员指南,我在星系标签上找到了一个技巧,将其用作信息亭

You can ask your app to be over the lock system and ask the return button to go back to a start activity/view of your app. I done this for a web View app

您可以要求您的应用程序越过锁定系统,并要求返回按钮返回到您的应用程序的开始活动/视图。我为 Web View 应用程序完成了此操作

    @Override
    public void onBackPressed() {
        //here asking to go back to home page
        mWebView.loadUrl(mHomepageUrl);
    }

for asking to stay up from the lock system, on the onCreate method :

在 onCreate 方法上要求保持锁定系统:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);

and then when you click on the power button twice , you found back your application , and only the back button is active on the status bar

然后当您单击电源按钮两次时,您会找到您的应用程序,并且状态栏上只有后退按钮处于活动状态

So the only way is to reboot the tablet (and so you can use the classic lock system with a code to open tablet)

所以唯一的方法是重启平板电脑(这样你就可以使用带有密码的经典锁定系统来打开平板电脑)

Can be useful if the power button is not accible by visitor , or if your are the only one who have the unlock code

如果访问者无法使用电源按钮,或者您是唯一拥有解锁码的人,则此功能很有用

回答by Hiren Patel

// Put code on onCreate method of your activity / fragment

// 将代码放在您的活动/片段的 onCreate 方法上

@Override
        @SuppressLint("NewApi")
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            getSupportActionBar().hide();
            setContentView(R.layout.activity_main);

              getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
        }