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

Доброе утро всем, у меня есть небольшая проблема с изменением размера раскладки при отображении клавиатуры.

enter image description here

enter image description here

В манифесте у меня есть AdjustResize, а также я пытался использовать AdjustPan, но у меня есть проблема с прокруткой просмотра в Recycle.

Мой код макета:

<LinearLayout
android:id="@+id/layoutGeneralHome"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".fragments.fragment_home">

<LinearLayout
    android:id="@+id/layoutRecycler"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.9">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/listChatGeneral"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.10"
    android:orientation="horizontal">

    <LinearLayout

        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.75"
        android:orientation="vertical">

        <EditText
            android:id="@+id/edtMessage"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:hint="Scrivi messaggio"/>

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.25">

        <Button
            android:id="@+id/btnSend"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="INVIA"
            android:textSize="18sp"/>

    </LinearLayout>

</LinearLayout>
</LinearLayout>

Спасибо, кто мог бы помочь мне

Ответы [ 2 ]

0 голосов
/ 10 января 2020

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:orientation="vertical">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/listChatGeneral"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/llSendView" />

    <LinearLayout
        android:id="@+id/llSendView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:gravity="center_vertical"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.75"
            android:orientation="vertical">

            <EditText
                android:id="@+id/edtMessage"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Scrivi messaggio" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.25">

            <Button
                android:id="@+id/btnSend"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="INVIA"
                android:textSize="18sp" />
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>
0 голосов
/ 10 января 2020

Это мой взгляд в моем приложении, он работает нормально, попробуйте это:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:mContext="hvasoftware.com.tudiendanhngon.view.activities.CommentActivity">




    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rvComment"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:visibility="gone"
        ads:layout_constraintBottom_toTopOf="@+id/viewComment"
        ads:layout_constraintTop_toBottomOf="parent" />


    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:indeterminate="true"
        android:indeterminateTint="@color/colorAccent"
        android:visibility="visible"
        ads:layout_constraintBottom_toBottomOf="parent"
        ads:layout_constraintLeft_toLeftOf="parent"
        ads:layout_constraintRight_toRightOf="parent"
        ads:layout_constraintTop_toTopOf="parent"
        tools:targetApi="lollipop" />


    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/viewComment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"

        >

        <EditText
            android:id="@+id/edtComment"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:fontFamily="sans-serif-light"
            android:inputType="textCapSentences"
            android:paddingLeft="9dp"
            android:paddingRight="50dp"
            android:textColor="@color/colorAccent"
            android:textSize="14sp"
            ads:layout_constraintBottom_toBottomOf="parent"
            ads:layout_constraintLeft_toLeftOf="parent"
            ads:layout_constraintRight_toLeftOf="@+id/ibUpComment" />

        <ImageButton
            android:id="@+id/ibUpComment"
            android:layout_width="23dp"
            android:layout_height="26dp"
            ads:layout_constraintBottom_toBottomOf="@id/edtComment"
            ads:layout_constraintRight_toRightOf="parent"
            ads:layout_constraintTop_toTopOf="@+id/edtComment" />


        <ProgressBar
            android:id="@+id/progressBarUpload"
            style="?android:attr/progressBarStyle"
            android:layout_width="26dp"
            android:layout_height="26dp"
            android:layout_centerInParent="true"
            android:layout_marginEnd="16dp"
            android:indeterminate="true"
            android:indeterminateTint="@color/colorAccent"
            android:visibility="gone"
            ads:layout_constraintBottom_toBottomOf="@id/edtComment"
            ads:layout_constraintRight_toRightOf="parent"
            ads:layout_constraintTop_toTopOf="@+id/edtComment"
            tools:targetApi="lollipop" />


    </androidx.constraintlayout.widget.ConstraintLayout>


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