Edittext在BottomSheetDialogFragment中被挤压

问题描述 投票:1回答:1

我有一个BottomSheetDialogFragment,其中有简单的布局文件当用户使用时,edittext在底部,recyclerview在顶部点击edittext并打开软键盘,并在其中写几行edittext并尝试滚动它,如果在滚动过程中我点击任意一行edittext会挤压自身,还会挤压BottomSheetDialogFragment混蛋就像它正在渲染自己。

这是我的代码

layout_file:

<RelativeLayout
   android:id="@+id/layout"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="@color/background"
   android:orientation="vertical"
   app:behavior_hideable="true"
   app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
   <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipeRefreshLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/etPostShare">
        <android.support.v7.widget.RecyclerView
             android:id="@+id/rvNewMessage"
             android:layout_width="match_parent"
             android:layout_height="match_parent"/>

   </android.support.v4.widget.SwipeRefreshLayout>
   <EditText
        android:id="@+id/etPostShare"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="1dp"
        android:background="@null"
        android:gravity="center|left"
        android:hint="Aa"
        android:inputType="textCapSentences|textMultiLine"
        android:isScrollContainer="true"
        android:maxHeight="60dp"
        android:maxLength="@integer/send_chat_txt_limit"
        android:maxLines="4"
        android:paddingLeft="18.4dp"
        android:paddingBottom="10dp"
        android:textSize="14.6sp" />

   </RelativeLayout>

我在此附上了本期的图片和视频链接:

enter image description here

https://drive.google.com/file/d/1bADuzDQoWep8XPMQ4ypKCWJyD32Gtfwp/view?usp=sharing

android android-fragments android-edittext keyboard-events bottom-sheet
1个回答
0
投票

可在预览中使用

 <RelativeLayout
            android:id="@+id/layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/holo_red_light"
            android:orientation="vertical"
            app:behavior_hideable="true"
            app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

            <android.support.v4.widget.SwipeRefreshLayout
                android:id="@+id/swipeRefreshLayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

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

            </android.support.v4.widget.SwipeRefreshLayout>

            <EditText
                android:id="@+id/etPostShare"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="1dp"
                android:background="@null"
                android:gravity="center|left"
                android:layout_alignParentBottom="true"
                android:hint="Aa\naa"
                android:inputType="textCapSentences|textMultiLine"
                android:isScrollContainer="true"
                android:maxHeight="60dp"
                android:maxLength="500"
                android:maxLines="4"
                android:paddingLeft="18.4dp"
                android:paddingBottom="10dp"
                android:textSize="14.6sp" />

        </RelativeLayout>
© www.soinside.com 2019 - 2024. All rights reserved.