Android stretch image,
Androidstretch images are in 9.png format. This image can be used to specify the part of the image to be stretched. The part of the displayed content can also be effectively displayed by the artist.
Original background imageProduction example 2.16.9.png
Open the Android sdk> tools> draw9patch.batand drag the image to start production.
Click around to add black spots. Drag black spots to line. Black lines and black spots around the image have different meanings.
The black line or point above indicates that the area that can be stretched vertically is generally a point.
Black lines or dots on the left represent a point in the area that can be horizontally stretched.
The following area indicates that the vertical content is generally a black line.
The area on the right that indicates horizontal content is generally a black line.
1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 3 android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" 4 android:paddingRight="@dimen/activity_horizontal_margin" 5 android:paddingTop="@dimen/activity_vertical_margin" 6 android:background="@android:color/darker_gray" 7 android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> 8 9 <TextView android:text="@string/hello_world"10 android:layout_width="wrap_content"11 android:layout_height="wrap_content"12 android:gravity="center_vertical"13 android:background="@drawable/bg"/>14 15 </RelativeLayout>
OK
Run the program
Note:Do not overlap the black spots on the left with the gaps on the right. Otherwise, the right side will be stretched.