android - ImageView 的背景和 src 属性的不同行为

标签 android material-design

我的应用中出现了这个奇怪的问题。我有 ImageView android:fitsSystemWindows="true" 并希望它出现在状态栏后面。

当我使用 android: background 时,它按预期正常工作,如下所示。 [注意状态栏中的蓝色背景]

enter image description here

但是当我使用 src 属性时,它不会在状态栏后面。

enter image description here

我错过了什么吗?感谢您的帮助。

这是我的 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/

相关文章:

java - 如何在单击时在回收器 View 中展开布局

android - 使用 DialogFragment 和导航库时将对话框显示为全屏或对话框

android - AndroidAnnotations 的 Rest 客户端日志记录

android - 3.0内核中的wakelock核心代码和接口(interface)与3.7/3.8有何区别?

android - 如何在图层列表中制作阴影?

android - 在不更改所选选项卡的情况下动态更新 TabLayout

mongodb - Angular 5 + Material 设计 : <mat-select> how to set the default value?

android - 为 BottomNavigationView 上的选定图标设置动画

javascript - 在客户端添加和删除附件(而不是替换以前的附件)

android - 如何在 RecyclerView 中使用拖动手势进行多选?