Mig*_*tor 3 android android-layout
这里的问题是,虽然我没有将fitsSystemWindows ="true"设置为xml中的任何标记,但它仍然看起来好像它具有fitsSystemWindows ="true".如果你没有看到差异,它就在状态栏部分.
结果现在:

我想要的是 :

额外细节:
我已经在styles.xml中将半透明状态设置为true(v21)
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="250dp"
android:fitsSystemWindows="false"
android:scaleType="fitXY"
android:src="@drawable/com_facebook_profile_picture_blank_portrait"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:fitsSystemWindows="false"
android:theme="@style/AppTheme.Toolbar"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
Run Code Online (Sandbox Code Playgroud)
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="a very long text, don't mind this, this is working as intended" />
Run Code Online (Sandbox Code Playgroud)
V21/styles.xml
<resources>
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
styles.xml
<resources>
<style name="AppTheme" parent="AppTheme.Base">
</style>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.Dark" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorPrimary</item>
</style>
<style name="AppTheme.Toolbar">
<item name="android:textColorPrimary">@color/white</item>
<item name="colorControlNormal">@color/white</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
Run Code Online (Sandbox Code Playgroud)
您需要在 /res/values-v21/styles.xml 中设置透明度:
<item name="android:statusBarColor">@android:color/transparent</item>
Run Code Online (Sandbox Code Playgroud)
或者以编程方式设置透明度:
getWindow().setStatusBarColor(Color.TRANSPARENT);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4544 次 |
| 最近记录: |