Note: This article is written by Colin, all rights Reserved! Reprint please specify the original address, thank you for your cooperation!
In the development of Android, we often need to set a background for the program, but because of the size of the current Android device, if you arbitrarily set a picture as the background, it is likely to be stretched on different devices, the user's visual experience will be poor, then how to solve this problem, Here's a rookie here to share the experience.
First, the need to define an XML file in the drawable-mdpi directory, where I named bitmap
Write the following code, specified in SRC as the name of the picture you want to tile:
<?xml version= "1.0" encoding= "Utf-8"? ><bitmap xmlns:android= "Http://schemas.android.com/apk/res/android" android:src= "@drawable/img01" android:id= "@+id/app_bg" android:tilemode= "repeat"/>
Second, in the layout configuration master file will be set the most external frame background to bitmap, as follows:
<?xml version= "1.0" encoding= "Utf-8"? ><scrollview xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Fill_parent "android:layout_height=" fill_parent "android:id=" @+id/content "Android: background= "@drawable/bitmap" ><textview android:layout_width= "wrap_content" android:layout_height= "Wrap_ Content "android:text=" @string/hello_world "/></scrollview>
At this point, run the virtual machine and see how it works.
Implementation effects such as (without the rounded rectangles and translucent effects in the diagram, the implementation of rounded rectangles see the next article):
Demo: Download Android rounded rectangle and semi-transparent demo
Set the background image tile in Android.