A bit late but maybe someone still needs it. Please consider that the in the following scenario I set the gravity
and the textAlignment
programmatically, depending on the position of the bubble, left or right.
This is how I managed to do this:
Normal View
Layout boundaries enabled
XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/chat_wrapper"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/message_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip">
<TextView
android:id="@+id/message_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="100dip"
android:paddingBottom="5dip"
android:textColor="#000000"/>
<TextView
android:id="@+id/message_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/message_text"
android:layout_below="@+id/message_text"
android:textColor="#000000"
android:textSize="9sp"/>
</RelativeLayout>
</LinearLayout>
Other info
The background is a 9-patch image that I set programmatically, can be found with a simple search. Tested on:
- Samsung Galaxy S4
- Android 22.0.1