【问题标题】:Bottomsheet Dialog hides UI elements底页对话框隐藏 UI 元素
【发布时间】:2017-11-21 08:56:20
【问题描述】:

我正在尝试使用带有编辑文本的底部对话框,我有这些屏幕截图:

在第二张图片中,键盘剪切了 UI 元素,应该将布局向上推。

这是我的代码

public void setUpBottomSheetDialog() {
    View bottomSheetDialog = getLayoutInflater().inflate(R.layout.bottom_layout2, null);
    bsDialog = new BottomSheetDialog(MainActivity.this);
    bsDialog.setContentView(bottomSheetDialog);
    bsDialog.setCanceledOnTouchOutside(false);
    bsDialog.setCancelable(true);

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical"
app:behavior_hideable="false"
app:behavior_peekHeight="56dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="30dp"
    android:gravity="center"
    android:orientation="horizontal"
    android:weightSum="1">
    <ImageView
        android:id="@+id/bs_imv_tag"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_gravity="center"
        app:srcCompat="@mipmap/ic_launcher_round" />
  <EditText
        android:id="@+id/bs_Etx"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_weight="0.99"
        android:ems="10"
        android:hint="type your note"
        android:inputType="textCapSentences|textMultiLine"
        android:maxHeight="80dp"
        android:maxLines="4"
        android:textColor="#000"
        android:textColorHint="#4e97bc" />
    <ImageView
        android:id="@+id/bs_imv_save"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_gravity="center"
        app:srcCompat="@mipmap/ic_launcher_round" />
</LinearLayout>
 <View
    android:layout_width="match_parent"
    android:layout_height="40dp" />
</LinearLayout>

你能告诉我在哪里修改吗?

【问题讨论】:

  • 在清单中尝试了adjustPan和adjustResize,没有成功

标签: android


【解决方案1】:

尝试使用

getActivity().getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

Reference this question

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-06
    • 1970-01-01
    • 1970-01-01
    • 2012-07-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多