android - 状态栏后面的布局 - Android Lollipop

标签 android android-5.0-lollipop transparent statusbar

我希望在我的应用程序中能够实现这个效果: enter image description here

其中状态栏是半透明的,布局在状态栏后面。我读过的关于这个主题的每个例子都主要与抽屉导航相关联,并且主要使用 ScrimInsetScrollView(或 ScrimInsetsFrameLayout)。我尝试使用 ScrimInsetsFrameLayout 实现它。

基本上我有一个包含 fragment 的 Activity ,这是我的布局( fragment 稍后添加到 Activity 的 onCreate 方法中的容器):

 <FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:fitsSystemWindows="true"
    >

    <com.test.app.widget.ScrimInsetsFrameLayout
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:insetForeground="#4000"
        android:id="@+id/container"
        ></com.test.app.widget.ScrimInsetsFrameLayout>

     </FrameLayout>

而且我还在主题中将 android:statusBarColor 设置为透明。 该解决方案对我不起作用。显然我在这里做错了什么。 有人可以指出我错在哪里吗?

最佳答案

你试过吗

@Override
public void onCreate(Bundle savedInstanceState) {
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

Android documentation 中所述

关于android - 状态栏后面的布局 - Android Lollipop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28945860/

相关文章:

android - BottomSheetDialogFragment 未显示

c# - 制作透明标签背景?

java - 由于 setOpaque(false) 方法,JPanel 不断被重新绘制

html - 透明gif不透明?

java - 如果有条件扩展一个类

java - 创建 Alarmobject 时应用程序崩溃 - Alarmmanager

java - 应用程序关闭时实现 Agora 信号通信

Android 在 Lollipop 及更高版本上自定义 EditText

android - Android 中的 AlwaysOnHotwordDetector 示例

Android 5.0 (Lollipop) CheckedTextView 按下高亮问题