gpt4 book ai didi

android - 在 Android 4 中覆盖导航栏

转载 作者:太空宇宙 更新时间:2023-11-03 11:10:48 25 4
gpt4 key购买 nike

尽管通过了一些样本,我仍在为此苦苦挣扎......

我想覆盖 android 导航栏——我试过下面的代码……

s_translucentParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_FULLSCREEN
,
PixelFormat.TRANSLUCENT);

但是,当然,它会填充一个不覆盖导航栏的窗口...阅读一些内容后,我尝试了以下操作(来自 Draw bitmaps on top of the Navigation bar in Android)...

w = new android.view.WindowManager.LayoutParams(-1, -1,0,-navigationBarHeight(),    WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_FULLSCREEN
|WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
|WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
|WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, Pixel.Translucent);
f.addView(v, w);

但是尽管我改变了窗口大小,但这并没有覆盖我......它只是不与导航栏重叠:(

我想做类似下面的东西......

https://play.google.com/store/apps/details?id=com.haxor&hl=en_GB

这不会显示在导航栏上方,而是显示在导航栏下方(这对我的需要很好)

谁能帮帮我?谢谢。

最佳答案

您在 Play Market 链接的屏幕截图中看到的是 Android KitKat (API 19) 半透明装饰。

You can now make the system bars partially translucent with new themes, Theme.Holo.NoActionBar.TranslucentDecor and Theme.Holo.Light.NoActionBar.TranslucentDecor. By enabling translucent system bars, your layout will fill the area behind the system bars, so you must also enable fitsSystemWindows for the portion of your layout that should not be covered by the system bars.

If you're creating a custom theme, set one of these themes as the parent theme or include the windowTranslucentNavigation and windowTranslucentStatus style properties in your theme.

您的半透明 Activity 应该在 AndroidManifest.xml 中声明,例如:

<activity android:name="com.example.app.TranslucentActivity"
android:theme="@android:style/Theme.Holo.NoActionBar.TranslucentDecor" />

您可能想采用的其他方法是使用 API 14+ 隐藏导航栏:

View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

或者您可能希望通过 API 19 使用沉浸式全屏模式:

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
decorView.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_STICKY);}
}

看看Using Immersive Full-Screen ModeHiding the Navigation Bar了解更多详细信息。

关于android - 在 Android 4 中覆盖导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25370509/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com