【发布时间】:2016-06-12 18:36:58
【问题描述】:
我在导航抽屉中有 ImageView,我不想用状态栏覆盖它。我已经尝试了一些来自互联网和 stackoverflow 的指令,包括“fitsSystemWindos = true”,添加半透明标志,但没有任何效果。有人可以帮忙吗? (顺便说一句,最小 api 21,在 Marshmallow 上测试)
我也有滚动的问题,它只是不起作用
v21/styles.xml
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
activity_main.xml 的第一部分
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
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">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!--Drawer Layout-->
<ScrollView
android:layout_width="240dp"
android:layout_height="match_parent"
android:background="@android:color/white"
android:layout_gravity="start"
android:fillViewport="true"
android:overScrollMode="always"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Header -->
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:src="@drawable/example"
android:id="@+id/drawer_header"
android:onClick="selfEdit"
android:layout_gravity="top"
android:scaleType="centerCrop" />
还有一些来自 MainActivity.java 的行
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(0x80000000);
【问题讨论】:
-
老兄,你的应用中有什么样的可绘制对象? @Dima
-
@ankitagrawal ImageView 来自 PNG。抱歉,忘记添加截图
-
可以加截图吗?
-
尝试添加
- true
-
@TusharSheth 应用程序现在全屏,状态栏隐藏,当我让他可见时 - 它是黑色的
标签: android android-layout navigation-drawer