android - RelativeLayout won't wrap right-aligned TextView -


in messaging app's xml right-aligned messages (outgoing), can't relativelayout wrap it's content (a textview that's aligned right). post picture, i'm new here, , need more reputation before that's possible.

the relativelayout containing text (message) has text bubble sort of background, , want nicely wrap around text. got working in other xml-file, left-aligned messages (incoming).

to specify, problem innermost relativelayout.

here's code:

<?xml version="1.0" encoding="utf-8"?>  <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:padding="10dp">      <relativelayout android:layout_width="fill_parent" android:layout_height="fill_parent"                     android:layout_marginstart="10dp">         <textview                 android:id="@+id/txtsender"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_alignparenttop="true"                 android:text=""                 android:textsize="16sp"                 android:singleline="true"                 android:layout_alignparentend="true"                 android:paddingright="10dp"                 android:paddingleft="10dp"                 android:textcolor="@android:color/black" android:textstyle="bold"/>          <textview                 android:id="@+id/txtdate"                 android:layout_alignparentstart="true"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:paddingleft="2dp"                 android:paddingright="2dp"                 android:paddingbottom="2dp"                 android:textsize="12sp"                 android:text=""                 android:layout_alignbottom="@+id/txtsender"                 />          <relativelayout                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_below="@+id/txtsender"                 android:padding="5dp"                 android:background="@drawable/purple_bubble"                 android:layout_alignparentend="true"                 android:layout_toendof="@+id/txtdate">              <textview                     android:id="@+id/txtmessage"                     android:paddingend="15dp"                     android:paddingstart="7dp"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_alignparentend="true"                     android:textcolor="@android:color/black"                     android:text="hello, how you?"/>         </relativelayout>     </relativelayout> </relativelayout> 

wrap linear layout inside relative layout. add layout gravity linear layout. how did it. can use reference,

 <?xml version="1.0" encoding="utf-8"?> <relativelayout   xmlns:android="http://schemas.android.com/apk/res/android"   android:layout_width="wrap_content"   android:layout_height="wrap_content">  <linearlayout     android:id="@+id/layoutsms"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_gravity="right"     android:layout_alignparentright="true"     android:background="@drawable/txt_green"     android:orientation="vertical">      <textview         android:id="@+id/txtsms"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="textview" />      <textview         android:id="@+id/txtsmsdate"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="right"         android:textcolor="#1e2ced"         android:text="textview"         android:textsize="10dp" />      </linearlayout> </relativelayout> 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -