adjustResize无法在棒棒糖及以上版本中使用半透明状态/导航

yww*_*ynm 10 android android-edittext android-5.0-lollipop

有问题谈论这个问题,但我没有通过现有的答案解决我的问题.

这是我的styles-v21.xml:

<style name="MainTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
    <item name="android:colorBackground">#EEEEEE</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我当然为相关的Activity设置了windowSoftInputMethod ="adjustResize".

这是我的layout.xml,注意根FrameLayout用于特定功能,因此需要它:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:id="@+id/rl_background"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <!--This View is used to fill the space of status bar-->
        <View
            android:id="@+id/statusbar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/statusbar_size"/>

        <!--I've set this toolbar as Actionbar-->
        <android.support.v7.widget.Toolbar
            android:id="@+id/actionbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:layout_below="@id/statusbar"/>

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/actionbar">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <!-- Two EditTexts inside -->

            </RelativeLayout>

        </ScrollView>

    </RelativeLayout>

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

当我没有触摸EditText时,一切看起来都很好:状态栏View保持原样,导航栏不覆盖内容(不要让内容不可见,但实际上内容不在其中).

在类似的问题中,人们经常教我们设置fitsSystemWindow ="true",我在layout.xml中的不同布局中做了这个,得到了不同的结果.

设置fitsSystemWindow ="true":

1.FrameLayout:AdjustResize有效,但状态栏View现在保持在真实状态栏下方.状态栏的颜色变为windowBackground.导航栏变得完全透明,因为它显示了添加此片段的其他片段内容.

2.First RelativeLayout:AdjustResize有效,但状态栏View低于实际状态栏.导航栏不太透明,无法显示其他片段,但覆盖内容.

ScrollView中的3&4.ScrollView和RelativeLayout:AdjustResize不起作用,其他条件与条件2相同.

我还使用了一种方法来编写我自己的FrameLayout,如下所示:https://stackoverflow.com/a/22266717/3952691 但正如作者所说,设置底部会导致错误.因为我使用半透明导航栏,我还需要绘制底部插图.我尝试升级版本:https://gist.github.com/romannurik/8919163,也没用.

很抱歉无法提供图片,但我真的需要帮助.谢谢!