我现在用的是最新的Android 4.4 FLAG_TRANSLUCENT_NAVIGATION
标记打开屏幕半透明的底部导航栏(后退,主页按钮等)。这工作正常,但这样做的副作用是我活动的布局现在显示在屏幕(虽然我还没有设置状态栏是半透明)顶部的状态栏下方。我想避免一个哈克修复即施加填充的布局的顶部。
I am using the new Android 4.4 FLAG_TRANSLUCENT_NAVIGATION
flag to turn the navigation bar (back, home button etc) at the bottom of the screen translucent. This works fine but a side effect of this is the layout of my Activity now displays beneath the status bar at the top of the screen (even though I have not set the status bar as being translucent). I want to avoid a hacky fix I.e. applying padding to the top of the layout.
有没有一种方法来设置导航半透明,同时确保状态栏显示正常,不允许布局,以显示它下面?
Is there a way to set the navigation as translucent whilst ensuring the status bar appears normally and does NOT allow the layout to display beneath it?
在code我现在用的就是如下:
The code I am using is as follows:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
感谢
ianhanniballake的回答实际工作,但你不应该使用安卓fitsSystemWindows =真正的
的顶层视图。此属性如下:
ianhanniballake's answer actually works, but you shouldn't use android:fitsSystemWindows="true"
on the toplevel view. Use this property as following :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/colorPrimaryDark">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff"
android:fitsSystemWindows="true">
<!-- Your other views -->
</LinearLayout>
</LinearLayout>
正如你所看到的,你必须设置在顶层观色,并把财产上的另一个容器。
As you can see, you have to set the color on the top-level view, and put the property on another container.
下一篇:旋转文本在画布画布、文本