【问题标题】:How to transparent status bar without change NaviBar android如何在不更改 NaviBar android 的情况下透明状态栏
【发布时间】:2017-08-26 04:24:29
【问题描述】:

我的麻烦是我不能像超级地图那样制作透明的状态栏。 这是超级制造的:

我尝试过使用

     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window w = getWindow(); // in Activity's onCreate() for instance
        w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    }

但它使所有状态和导航栏变得透明。我不想这样。只是状态栏。你能帮帮我吗,伙计?只要点击评论任何建议我的东西

我的代码:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    style="@style/AppThemeMap"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:openDrawer="start">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <include
            layout="@layout/app_bar_maps"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </RelativeLayout>
    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        android:visibility="visible"
        app:headerLayout="@layout/nav_header_maps"
        app:itemTextAppearance="@style/NavigationDrawerStyle"
        app:menu="@menu/activity_maps_drawer"
        app:theme="@style/NavigationDrawerStyle">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:orientation="vertical">
            <goixeom.com.CustomTextView
                android:id="@+id/term"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingBottom="@dimen/size_margin_nav"
                android:layout_marginLeft="72dp"
                android:text="Quyền riêng tư"
                android:textStyle="bold" />
            <goixeom.com.CustomTextView
                android:id="@+id/dang_xuat"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingBottom="@dimen/size_margin_nav"
                android:layout_marginLeft="72dp"
                android:text="Điều khoản"
                android:textStyle="bold" />
        </LinearLayout>
    </android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>

我的应用截图: 谢谢!

【问题讨论】:

  • 你想让你的应用中的所有状态栏都是透明的吗?
  • 是的。所有状态栏,但不影响导航栏。
  • 在下面查看我的答案
  • 你是怎么解决这个问题的?

标签: android dictionary statusbar transparent


【解决方案1】:

只需将此行添加到您的基本应用程序主题

<item name="android:windowTranslucentStatus">true</item>

或以编程方式

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}

【讨论】:

    【解决方案2】:

    只需在活动中添加这些行

     getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                getWindow().setStatusBarColor(Color.TRANSPARENT);
            }
    

    【讨论】:

    • 好吧,它只会使状态栏颜色变灰。我的地图不适合状态栏,颜色状态不透明。我在我的问题中添加了源代码。
    • 您是否从样式中删除了 true
    猜你喜欢
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-10
    • 1970-01-01
    • 2016-10-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多