Issue
I'm trying to implement a chat activity where the background of the EditText is transparent, so on scrolling up the messages are visible behind the Edittext. But this is the result :
As you can see it is not perfect, I want to be able to scroll a little more to make messages above the edittext
completely not behind it!
<androidx.recyclerview.widget.RecyclerView
android:layout_below="@+id/bar_layout"
android:id="@+id/recycle_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="LinearLayoutManager"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"
android:overScrollMode="never"
/>
<RelativeLayout
android:id="@+id/bottom"
android:layout_width="match_parent"
android:padding="5dp"
android:layout_margin="@dimen/_10sdp"
android:background="@android:color/transparent"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content">
<EditText
android:id="@+id/text_send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/btn_send"
android:background="@drawable/sendmessage"
android:hint="Type a message ... "
android:padding="8dp"
android:layout_centerVertical="true"
/>
<ImageButton
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_margin="5dp"
android:id="@+id/btn_send"
android:background="@drawable/ic_paper_plane"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
Solution
Wrap it all in a LinearLayout
with orientation="vertical"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".MainActivity"
android:id="@+id/root">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycle_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"
app:layoutManager="LinearLayoutManager" />
<RelativeLayout
android:id="@+id/bottom"
android:layout_width="match_parent"
android:padding="5dp"
android:background="@android:color/transparent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<EditText
android:id="@+id/text_send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/btn_send"
android:hint="Type a message ... "
android:padding="8dp" />
<ImageButton
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_margin="5dp"
android:id="@+id/btn_send"
android:background="#000000"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
</RelativeLayout>
Answered By - Jakob
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.