我想是这样的整合:半透明状态栏和工具栏
而且我已经做到了这样,但我似乎无法把工具栏下面的ImageView的。没有工具栏,我可以在状态栏下进行设置,但将这两者结合起来是不可能的。
这里是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
tools:context="com.project.android.PhotoActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/photo_tl"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#59000000"
tools:ignore="UnusedAttribute" />
<ImageView
android:id="@+id/photo_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="fitStart" />
</LinearLayout>
在我的活动,我已经做了以下内容:
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
我也宣布了风格,v21.xml文件:
<style name="Project.Photo" parent="Project.Light">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#59000000</item>
</style>
并将其设置为PhotoActivity的默认样式。 我已经尝试过把工具栏中的FrameLayout,但这样做,我的工具栏只是隐藏,像这样:
在此先感谢。
得到了修正,但工具栏与状态栏重叠。无论如何修复填充?如果我使用android:fitsSystemWindows =“true”,状态栏不再是半透明的。
不要忘记检查它在Android上的每一个版本,因为他们改变了API每一个主要版本。 –
同样的问题,请参阅本http://stackoverflow.com/questions/29738510/toolbar-overlapping-below-status-bar –
见我的答案在这里:http://stackoverflow.com/a/41707177/1543839 – Isaac