小编Ram*_*h K的帖子

带键盘调整调整大小的 Android BottomSheetBehavior

我在活动中有以下布局。

<CoordinatorLayout ...>
  <ScrollView ...>
    <LinearLayout
      ...
      android:orientation="vertical">
      <!-- Some stuff -->
      <EditText ...>
      <!-- Some more stuff -->
      <View
        android:id="@+id/keyboard_extender"
        ...>
    </LinearLayout>
  </ScrollView>
  <LinearLayout
    android:id="@+id/bottom_sheet"
    android:orientation="vertical"
    ...
    app:layout_behavior="android...BottomSheetBehavior">
    <!-- Even more stuff -->
  </LinearLayout>
</CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

我希望键盘不bottom_sheet应该向上推,但应该向上推keyboard_extender. 请注意,这bottom_sheet不是一个,BottomSheetDialog而只是一个使用android.support.design.widget.BottomSheetBehavior. 这不能更改为 aBottomSheetDialog因为我希望屏幕的其余部分与bottom_sheet

我从未将 的可见性设置bottom_sheetView.GONE。我只能从改变其状态BottomSheetBehavior.EXPANDED,以BottomSheetBehavior.COLLAPSED和背部。另外,我希望bottom_sheet只有当键盘不可见时才可见。

由于我需要keyboard_extender始终在键盘上方,因此我在 AndroidManifest.xml 中设置了android:windowSoftInputMode="adjustResize"(我认为这是不可避免的)

我有一个方法,当调用它时应该隐藏键盘并显示bottom_sheet,但我面临的问题是在键盘开始隐藏的同时bottom_sheet开始动画BottomSheetBehavior.EXPANDED,当键盘开始隐藏时,屏幕实际上被调整大小因为windowSoftInputMode="adjustResize" …

android android-softkeyboard bottom-sheet

6
推荐指数
0
解决办法
2533
查看次数