我制作了某种聊天应用程序,其布局包含工具栏,RecyclerView和用于发送消息的面板(如图所示)。我尝试实现以下行为:当键盘打开带有EditText AND RecyclerView的面板时,向上推,但是Toolbar仍然可见。这里是在VK应用程序中实现的:
这是我的布局,得到的结果
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".activity.DialogActivity">
<include layout="@layout/toolbar_dialog" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/send_message_layout"
android:clipToPadding="false"
android:divider="@null"
android:paddingTop="8dp"
android:background="#EAEFF2"
android:paddingBottom="8dp" />
<LinearLayout
android:id="@+id/send_message_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:elevation="8dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<ImageView
android:id="@+id/iv_image"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:alpha=".5"
android:background="?selectableItemBackground"
android:contentDescription="@string/app_name"
android:padding="2dp"
android:src="@mipmap/ic_launcher" />
<EditText
android:id="@+id/et_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textMultiLine"
android:maxLines="3"
android:hint="Ваше сообщение"
android:background="@android:color/transparent"
/>
<Button
android:id="@+id/btn_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
</LinearLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
清单中:
android:windowSoftInputMode="adjustResize"
结果:
您可以看到我的RecyclerView被EditText和键盘覆盖。我尝试过adjustPan
,但它隐藏了我的工具栏。您能否带给我解决方案来实现VK这样的行为。
我有同样的问题。您找到解决方案了吗?