我的应用中出现了这个奇怪的问题。我有 ImageView android:fitsSystemWindows="true"
并希望它出现在状态栏后面。
当我使用 android: background
时,它按预期正常工作,如下所示。 [注意状态栏中的蓝色背景]
但是当我使用 src 属性时,它不会在状态栏后面。
我错过了什么吗?感谢您的帮助。
这是我的 Activity XML。
<?xml version="1.0" encoding="utf-8"?>
<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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<ImageView
android:id="@+id/full_background"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:scaleType="centerCrop"
android:contentDescription="full_background"
tools:ignore="HardcodedText" />
<include
layout="@layout/app_bar_activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/nav_header_activity_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
最佳答案
尝试使用: FLAG_LAYOUT_NO_LIMITS
IT 允许窗口扩展到屏幕之外
Window window = getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
关于android - ImageView 的背景和 src 属性的不同行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47958202/