FitssystemWindows打破了透明操作栏

时间:2018-08-07 16:01:27

标签: android xml android-layout android-styles

我正在尝试使用透明的操作栏和子元素的背景图片进行活动。但这仅在未为root活动元素设置fitssystemwindows时有效。我需要fitssystemwindows,因为没有它,则会忽略windowSoftInputMode。 因此,是否可以同时实现:

  1. 操作栏是透明的
  2. 子元素的背景图片为 二手
  3. windowSoftInputMode为AdjustResize ?

如果我不使用fitssystemwindows,则操作栏是透明的,但是adjustResize被忽略。 如果我使用fitssystemwindows = true,则操作栏将变得不透明。 我的透明操作栏样式:

<style name="TransparentStatusBarWithActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:actionBarStyle">@style/ThemeActionBar</item>
    <item name="android:windowActionBarOverlay">true</item>
    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/ThemeActionBar</item>
    <item name="windowActionBarOverlay">true</item>
</style>

我的活动的xml:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".ui.activity.signupemail.SignUpEmailActivity"
    android:background="@drawable/bg" //  have to use this, because fitsSystemWindows brokes transparent action bar with child background
    android:fitsSystemWindows="true"
    >
<ScrollView 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"
    >
    <LinearLayout
    <!--android:background="@drawable/bg" couldn't use this -->
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            ...
        </LinearLayout>
</ScrollView>
    <include layout="@layout/view_progress_bar"/>
</FrameLayout>

0 个答案:

没有答案
相关问题