Android Launcher How to achieve center wallpaper

Source: Internet
Author: User

Objective
welcome everyone I share and recommend useful code Snippets ~ ~
Statement
Welcome reprint, but please keep the original source of the article:
CSDN:
http://www.csdn.net
rainy season o mo away:http://blog.csdn.net/luckkof

Body

KK Launcher3 Wallpaper display is dynamic, related to the number of launcher preset desktop, let the wallpaper center, only to ensure that the first time the wallpaper center, after the user modified the number of desktops, will not be able to achieve. How to center the default number of desktops in the configuration, you can refer to the following method, the default one screen as an example:Replace the Launcher3 Workspace.java file with the following functionprivate voidUpdateoffset(Boolean force) {
if (mwaitingforupdate | | force) {
Mwaitingforupdate = false;
LAUNCHERLOG.D (TAG, "updateoffset:mwallpaperoffset =" + Mwallpaperoffset.getcurrx ());
if (Computescrolloffset () && Mwindowtoken! = null) {
try {
if (Getchildcount () <= 1) {
LAUNCHERLOG.D (TAG, "Wallpaperoffset 111");
Mwallpapermanager.setwallpaperoffsets (Mwindowtoken,
/* MWALLPAPEROFFSET.GETCURRX () */0.5f, 0.5f);
}else{
LAUNCHERLOG.D (TAG, "Wallpaperoffset 222");
Mwallpapermanager.setwallpaperoffsets (Mwindowtoken,
Mwallpaperoffset.getcurrx (), 0.5f);
}
Setwallpaperoffsetsteps ();
} catch (IllegalArgumentException e) {
LOG.E (TAG, "Error Updating wallpaper offset:" + e);
}
}
}
}

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.