I implemented the following TextView in a RelativeView:
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/bg"/>
The problem is that the size will be set dynamically to 15% of the screen while the application is running. But when I do this the background ressource doesn’t get the size of the TextView. It has the original size of 150x150 px. What can I do to avoid this?
(I don’t want to take a smaller ressource because it doesn’t look well then)
Try using another
scaleType, for exampleandroid:scaleType="fitXY".Also you can try making a nine-patch image. To do this, go to your Android SDK folder – tools – draw9patch application. Then you will have options to open your image and then save it as nine-patch image. Reference it as usual in your layout.