I'm trying to create a simple Android chat app. What I need to do is create a chat bubble around the chat text. The width of this bubble can should not be greater than 85% of the width of the screen, even if it contains more text (the text should move to the next line). However, if the amount of text is less in the bubble, the width of the bubble should wrap the content.
The reason for this is that I'm displaying the time of the chat to the right of the Bubble, and if the bubble width becomes greater than 85% screen size, the date won't be visible.
Below is the layout file:
<TextView
android:id="@+id/chatBody"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Chat Text"
android:textColor="#222222"
android:textSize="19sp"
android:textStyle="bold"/>
<TextView
android:id="@+id/chatDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:gravity="right"
android:text="Date"
android:textColor="#999999"
android:textSize="12sp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="20dp"/>
</LinearLayout>