У меня есть макет чата, такой как WhatsApp, с SwipeBackLayout в качестве родительского макета, проблема в том, что когда мой текст редактирования получает фокус, клавиатура поднимает его и размер фона изменяется. Я использовал android:windowSoftInputMode="adjustPan"
, и это работает, но панель инструментов покидает экран. Также я попытался установить фоновое изображение в окне действия в styles
с <item name="android:windowBackground">@drawable/user_chat_background</item>
, но SwipeBackLayout потерял свою прозрачность, и я не хочу этого.
Скриншоты:
Без клавиатуры
https://i.imgur.com/K66jHR4.png
Когда появляется клавиатура
https://imgur.com/vfUeBkt.png
Извините, я пока не могу опубликовать изображения: c
Это мой код активности_Layout:
<com.gw.swipeback.SwipeBackLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:directionMode="left"
app:isSwipeFromEdge="true"
app:maskAlpha="180"
app:swipeBackFactor="0.5"
tools:context=".activities.ChatActivity">
<RelativeLayout
android:id="@+id/parent_layout"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:background="@drawable/user_chat_background"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/chat_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:contentInsetStart="4dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:id="@+id/card_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="14dp"
android:layout_marginBottom="4dp"
app:cardBackgroundColor="@color/colorPrimary"
app:cardCornerRadius="20dp"
app:cardElevation="10dp">
<LinearLayout
android:id="@+id/layout_back"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/toolbar_ripple"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="3dp">
<ImageView
android:id="@+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_arrow_back" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/custom_profile_image"
android:layout_width="35dp"
android:layout_height="35dp"
android:cropToPadding="true"
android:src="@drawable/profile_image"
android:transitionName="@string/profile_image_shared" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/custom_profile_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/card_view"
android:text="Display username"
android:textColor="@color/colorAccent"
android:textSize="18sp"
android:textStyle="bold"
android:transitionName="@string/user_name_shared" />
<TextView
android:id="@+id/custom_user_last_seen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/custom_profile_name"
android:layout_toRightOf="@id/card_view"
android:text="Last seen"
android:textColor="@color/colorAccent"
android:textSize="14sp"
android:transitionName="@string/status_shared" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/private_messages_list_of_users"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/my_linear_layout"
android:isScrollContainer="false"
android:layout_below="@id/chat_toolbar">
</androidx.recyclerview.widget.RecyclerView>
<LinearLayout
android:id="@+id/my_linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_margin="1dp"
android:gravity="bottom"
android:orientation="horizontal"
android:padding="2dp"
android:weightSum="30">
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:layout_weight="25.8"
app:cardCornerRadius="25dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="horizontal"
android:weightSum="8">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.1"
android:gravity="bottom"
android:paddingStart="2dp"
android:paddingEnd="2dp"
android:paddingBottom="6dp">
<ImageButton
android:id="@+id/emoji"
android:layout_width="match_parent"
android:layout_height="36dp"
android:background="@drawable/icons_ripple"
android:onClick="emojiAction"
android:src="@drawable/ic_emoji" />
</LinearLayout>
<EditText
android:id="@+id/input_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="4.8"
android:background="#00000000"
android:hint="@string/type_a_message"
android:inputType="textCapSentences|textMultiLine"
android:maxLength="2000"
android:maxLines="6"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:scrollbarStyle="outsideInset"
android:scrollbars="vertical"
android:textColorHighlight="#18DD7D"
android:textSize="18sp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2.1"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingStart="2dp"
android:paddingEnd="2dp"
android:paddingBottom="6dp"
android:weightSum="2">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_weight="1"
android:background="@drawable/icons_ripple"
android:src="@drawable/ic_attach_file" />
<ImageButton
android:id="@+id/camera_button"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_weight="1"
android:background="@drawable/icons_ripple"
android:src="@drawable/ic_camera" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<ImageButton
android:id="@+id/send_message_button"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="2dp"
android:layout_marginBottom="5dp"
android:layout_weight="4.2"
android:background="@drawable/chat_ripple"
android:src="@drawable/ic_mic" />
</LinearLayout>
</RelativeLayout>
</com.gw.swipeback.SwipeBackLayout>```