alignParentBottom 切换可见性

alignParentBottom with toggling visibility

我有这样的布局:

<CoordinatorLayout>
    <RelativeLayout id="parent">
        <LinearLayout id="child1"
                      layout_above="+id/child2"/>
        <LinearLayout id="child2"
                      gravity="bottom"
                      alignParentBottom="true"
                      visibility="gone"/>
    <FloatingActionButton/>
</CoordinatorLayout>

布局 child2(默认情况下已消失)中有一个 EditText 和一个 Button,垂直对齐。在执行某些操作时,当焦点位于 EditText 上时,我希望 child2 位于键盘顶部。当该操作发生时,我将 child2 的可见性切换为 VISIBLE,但问题是当键盘启动时只有 EditText 可见,而不是其下方的 Button

当我从布局中取出 visibility=GONE 时,它工作正常。整个 child2 按预期固定在键盘上,但是当我默认将其设置为 GONE 并使其在我的操作中可见时,只有 EditText 在键盘和整个视图上方可见没有固定在键盘上。我还在 Activity 中尝试了 adjustResize,但效果不佳。有什么想法我错过了什么吗?

我意识到我的 activity 正在设置 FLAG_FULLSCREEN 因为它忽略了 docs:

中所述的 windowSoftInputMode 值

Window flag: hide all screen decorations (such as the status bar) while this window is displayed. This allows the window to use the entire display space for itself -- the status bar will be hidden when an app window with this flag set is on the top layer. A fullscreen window will ignore a value of SOFT_INPUT_ADJUST_RESIZE for the window's softInputMode field; the window will stay fullscreen and will not resize.

一个相当尴尬的时刻! (捂脸)