как изменить размер нижнего листа при открытой клавиатуре? - PullRequest
0 голосов
/ 05 апреля 2020

Я использую один BottomSheet, который я определил как STATE_EXPANDED. У меня есть 3 edittext в нижней таблице. Я принудительно установил edittext, когда открыт нижнюю таблицу. Когда нижняя таблица открыта, клавиатура открывается одновременно. Так что проблем с использованием * нет. 1019 *: windowSoftInputMode = "stateVisible | AdjustResize" в Linearlayout. При открытии нижнего листа появляется изображение, подобное этому;

введите описание изображения здесь

, но моя цель - здесь;

введите описание изображения здесь

Я имею в виду, что когда edittext выбран при открытии нижнего листа, я хочу, чтобы пространство внизу было таким же, как клавиатура чтобы появилось меню.

вот мои коды;

<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="match_parent"
android:padding="16dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:background="?attr/bottombarcolor"
android:windowSoftInputMode="stateVisible|adjustResize"
android:fitsSystemWindows="true">

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="?actionBarSize"
    android:orientation="horizontal"
    android:layout_marginBottom="10dp"
    android:backgroundTint="?attr/colorPrimary">

    <com.google.android.material.button.MaterialButton
        android:id="@+id/btn_back"
        style="@style/Widget.MaterialComponents.Button.TextButton.Icon"
        android:layout_width="60dp"
        android:layout_weight="0"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:textColor="?attr/textcolor"
        app:icon="@drawable/ic_arrow_back_black_24dp"
        app:iconGravity="start"
        app:iconTint="?attr/colorPrimary"
        android:backgroundTint="?attr/bottombarcolor"/>

    <com.google.android.material.textfield.TextInputLayout
        style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="@string/dropdownlist"
        app:hintTextColor="?attr/colorPrimary"
        app:boxBackgroundColor="?attr/bottombarcolor"
        android:layout_weight="1"
        android:textColorHint="?attr/textcolor"
        app:boxCollapsedPaddingTop="2dp">

        <AutoCompleteTextView
            android:id="@+id/filled_exposed_dropdown"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="sdfsdfsfsg"
            android:inputType="none"
            android:fontFamily="@font/regularopensans"
            android:textColor="?attr/textcolor" />

    </com.google.android.material.textfield.TextInputLayout>




    <com.google.android.material.button.MaterialButton
        android:id="@+id/btn_apply"
        style="@style/Widget.MaterialComponents.Button.TextButton.Icon"
        android:layout_width="60dp"
        android:layout_weight="0"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:textColor="?attr/textcolor"
        app:icon="@drawable/ic_check_black_24dp"
        app:iconGravity="end"
        app:iconTint="?attr/colorPrimary"
        />

</LinearLayout>
<View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_marginBottom="16dp"
    android:background="@android:color/white"
    android:backgroundTint="?attr/colorPrimary"/>



<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="4dp"
    android:text="@string/newtask"
    android:textColor="?attr/textcolor"
    android:fontFamily="@font/regularopensans"/>

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/outlinedTfNew"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/entertask"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    app:hintTextColor="?attr/colorPrimary"
    android:textColorHint="?attr/textcolor"
    app:boxStrokeColor="?attr/textcolor"
    app:boxStrokeWidth="0dp"
    app:endIconMode="clear_text"
    app:startIconDrawable="@drawable/ic_mic_black_24dp"
    app:endIconTint="?attr/colorPrimary"
    app:startIconTint="?attr/colorPrimary">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/txteditNew"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="?attr/textcolor"
        android:fontFamily="@font/lightopensans" />
    <requestFocus />

</com.google.android.material.textfield.TextInputLayout>
<View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_marginBottom="16dp"
    android:background="@android:color/white"
    android:backgroundTint="?attr/textcolor"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/taskcompdate"
    android:textColor="?attr/textcolor"
    android:textAlignment="center"
    android:fontFamily="@font/regularopensans"/>

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/outlinedTfComp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/nodate"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    app:hintTextColor="?attr/colorPrimary"
    android:textColorHint="?attr/textcolor"
    app:boxStrokeColor="?attr/textcolor"
    app:boxStrokeWidth="0dp"
    app:endIconMode="clear_text"
    app:startIconTint="?attr/colorPrimary"
    app:startIconDrawable="@drawable/ic_today_black_24dp"
    app:endIconTint="?attr/colorPrimary">

    <com.google.android.material.textfield.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="?attr/textcolor"
        android:fontFamily="@font/lightopensans"/>

</com.google.android.material.textfield.TextInputLayout>
<View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_marginBottom="16dp"
    android:background="@android:color/white"
    android:backgroundTint="?attr/textcolor"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/tasktime"
    android:textColor="?attr/textcolor"
    android:fontFamily="@font/regularopensans"
    android:textAlignment="center"/>

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/outlinedTfTime"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/notime"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    app:hintTextColor="?attr/colorPrimary"
    android:textColorHint="?attr/textcolor"
    app:boxStrokeColor="?attr/textcolor"
    app:boxStrokeWidth="0dp"
    app:endIconTint="?attr/colorPrimary"
    app:endIconMode="clear_text"
    app:startIconDrawable="@drawable/ic_access_time_black_24dp"
    app:startIconTint="?attr/colorPrimary">

    <com.google.android.material.textfield.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="?attr/textcolor"
        android:fontFamily="@font/lightopensans" />

</com.google.android.material.textfield.TextInputLayout>


<View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_marginBottom="16dp"
    android:background="@android:color/white"
    android:backgroundTint="?attr/textcolor"
    />

Когда я нажимаю на нижний текст редактирования, возникает нужная ситуация. Я хочу, чтобы это происходило, когда первый текст редактирования выбран.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...