Add a custom wallpaper to luncher (modify the luncher interface and modify the wallpaper in the Program)

Source: Internet
Author: User

First, prepare two images with the same content. The specifications are 107 × 80 640 × 480, and the format is JPG. Then, name them wallpaper_papername_small and wallpaper_papername respectively. Papername is the name you give to the image. The small image is used to display in the gallery control that selects wallpaper. Wallpaper_papername is the wallpaper image.

Put the image in the/packages/apps/launcher2/RES/drawable-mdpi directory. Add <item> wallpaper_papername </item> to the file/packages/apps/launcher2/RES/Values-mdpi/wallpapers. xml.

<?xml version="1.0" encoding="utf-8"?><resources>    <string-array name="wallpapers" translatable="false">         <item>wallpaper_lake</item>        <item>wallpaper_sunset</item>        <item>wallpaper_beach</item>        <item>wallpaper_snow_leopard</item>        <item>wallpaper_path</item>        <item>wallpaper_sunrise</item>        <item>wallpaper_mountain</item>        <item>wallpaper_road</item>        <item>wallpaper_jellyfish</item>        <item>wallpaper_zanzibar</item>        <item>wallpaper_blue</item>        <item>wallpaper_grey</item>        <item>wallpaper_green</item>        <item>wallpaper_pink</item>        <item>wallpaper_leaves</item>    </string-array></resources>

If you do not want to modify the luncher source code, but want to modify the wallpaper in your own program, you can use the following method:

First, we need to obtain the permission to set the wallpaper. Like other permissions, you only need to add the following configuration information to the configuration file.
<Uses-Permission Android: Name = "android. Permission. set_wallpaper"/>
Then, call the following code in the program to set the desktop Wallpaper:
Getapplicationcontext (). setwallpaper (Bitmap)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.