I am making a chat bubble. I made the bubble using 9patch image. But I want to resize the bubble according to the size of textview.. How to do it ?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:background="@drawable/senderbubble2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<TextView
android:id="@+id/txt_msg"
android:text="hello world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
The above is my xml code of chat bubble...
You can get the height & width of textView, by calling below methods on textview reference, below method returns int value, you can use it to resize image.
see documentation for more details https://developer.android.com/reference/android/view/View.html