Почему мой макет редактирования текста и клавиатура перекрываются? - PullRequest
0 голосов
/ 09 апреля 2019

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

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/rootLayout"
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@android:color/white">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="@dimen/footer_height"
        android:layout_alignParentTop="true"
        android:background="@color/colorPrimary"
        android:elevation="1dp"
        android:orientation="horizontal">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <Button
                android:id="@+id/chat_back_button"
                style="@style/Base.Widget.AppCompat.Button.Borderless"
                android:layout_width="80dp"
                android:layout_height="40dp"
                android:layout_centerVertical="true"
                android:background="@drawable/image_back"/>

            <TextView
                android:id="@+id/chat_Header_textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="@string/str_chat"
                android:textColor="@android:color/white"
                android:textSize="@dimen/activity_list_header_size"/>
        </RelativeLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="50dp"
        android:layout_marginTop="54dp">

        <ListView
            android:id="@+id/chat_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/white"
            android:divider="@null"
            android:dividerHeight="0dp"
            android:transcriptMode="alwaysScroll"></ListView>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/chat_edit_layout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@color/colorPrimaryDark"
        android:orientation="vertical"
        android:padding="0.5dp"
        android:layout_above="@+id/chat_footer_layout"
        android:layout_centerHorizontal="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/white"
            android:orientation="horizontal">

            <EditText
                android:id="@+id/chat_edit"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.8"
                android:background="@android:color/white"
                android:gravity="start|center_vertical"
                android:hint="@string/mesaj_yaz"
                android:padding="2dp"/>

            <ImageView
                android:id="@+id/chat_send"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.2"
                android:onClick="sendMessage"
                android:src="@drawable/chat_icon"
                android:visibility="gone"/>

            <TextView
                android:id="@+id/chat_text"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.3"
                android:background="@color/colorPrimaryDark"
                android:gravity="center"
                android:onClick="sendMessage"
                android:text="@string/gonder"
                android:textColor="@android:color/white"
                android:textSize="@dimen/activity_list_header_size"/>

        </LinearLayout>

    </LinearLayout>

    <RelativeLayout
        android:id="@+id/chat_footer_layout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/footer_height"
        android:layout_alignParentBottom="true"
        >
        <!--android:elevation="1dp"-->

        <ImageView
            android:id="@+id/chat_footer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="fitXY"/>
    </RelativeLayout>

Я добавил getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); в методе onCreate (). Также я добавил android:windowSoftInputMode="adjustResize" к активности в Manifest.xml. Но все равно не работает.

1 Ответ

0 голосов
/ 11 апреля 2019

попробуйте scrollView в качестве родительского макета и используйте "AdjustPan" в манифесте

    android:id="@+id/main_parent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
...