【问题标题】:Translucent Status Bar is not translucent半透明状态栏不半透明
【发布时间】:2021-04-22 15:18:28
【问题描述】:

我已经尝试实现半透明的操作栏,就像描述的here

效果应该是这样的:

我对布局进行了以下更改:

> <androidx.coordinatorlayout.widget.CoordinatorLayout  
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".fragments.HotelFragment">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:fitsSystemWindows="true">

        <com.google.android.material.appbar.CollapsingToolbarLayout
            .....
            android:fitsSystemWindows="true">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/d" />

            <androidx.appcompat.widget.Toolbar
                     ....
                android:background="@android:color/transparent"
               />

        </com.google.android.material.appbar.CollapsingToolbarLayout>
    </com.google.android.material.appbar.AppBarLayout>

在主题中:

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

效果是这样的:

我的最低 API 是 21。

【问题讨论】:

    标签: android material-design


    【解决方案1】:

    将此添加到活动中。 window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)

    【讨论】:

    • 它可以工作,但导航栏没有这个状态栏形式的额外空间。状态栏有点包含在工具栏中。
    猜你喜欢
    • 1970-01-01
    • 2016-04-18
    • 2011-02-22
    • 1970-01-01
    • 2015-04-07
    • 1970-01-01
    • 1970-01-01
    • 2022-10-14
    • 1970-01-01
    相关资源
    最近更新 更多