小编Fun*_*nts的帖子

底部工作表对话框横向宽度问题

Bottom_sheet_image_dialog.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behavior_hideable="false"
app:behavior_peekHeight="62dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/llAddDriverPic"
    android:background="?android:attr/selectableItemBackground"
    android:padding="8dp">

    <ImageView
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:src="@drawable/baseline_add_photo_alternate_24"
        android:layout_margin="8dp"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/add_picture"
        android:layout_gravity="center_vertical"
        android:padding="8dp"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/llRemoveDriverPic"
    android:background="?android:attr/selectableItemBackground"
    android:padding="8dp">

    <ImageView
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:src="@drawable/baseline_no_photography_24"
        android:layout_margin="8dp"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/remove_picture"
        android:layout_gravity="center_vertical"
        android:padding="8dp"/>

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

代码实现:

BottomSheetDialog bsDialog = new BottomSheetDialog(getContext());
bsDialog.setContentView(R.layout.bottom_sheet_image_dialog);

bsDialog.setOnShowListener(dialog -> {
    BottomSheetBehavior bottomSheetBehavior = ((BottomSheetDialog)dialog).getBehavior();
    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
});
Run Code Online (Sandbox Code Playgroud)

出现以下问题:视频中看到的宽度不会完全显示。如果我在横向模式下从一开始就启动底页,则宽度看起来也会有所不同,因为左侧和右侧未被覆盖:

示例Lendscape

可能存在什么问题?在显示对话框之前是否需要预先定义宽度?

android dialog width material-design bottom-sheet

5
推荐指数
1
解决办法
1903
查看次数

使用多行 TextField 在所选行下方显示键盘

所以我有以下布局 TextInputEditText

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/note"
    android:layout_marginTop="@dimen/layout_margin_default"
    app:startIconDrawable="@drawable/baseline_notes_24">
    <com.google.android.material.textfield.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textMultiLine"
        />
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)

现在,当我选择在键盘内书写时,TextInputEditText键盘会自动显示在以下位置TextInputEditText编辑文本下方

现在,我想要的是,而不是在 下方显示键盘TextInputEditText,我希望显示在当前“选定”行下方的键盘,该行应如下所示: 线下1 线下2

示例视频应该是什么样子: https://jumpshare.com/v/TAO6jo1jdnRZDhYyzrkY

如何以正确的方式解决这个问题?我尝试过使用android:windowsoftinputmode,但找不到合适的属性。

我假设在显示键盘方面没有太多余地?

keyboard android android-softkeyboard android-edittext android-textinputlayout

5
推荐指数
0
解决办法
84
查看次数