今天和大家分享的是关于在Android中设置壁纸的方法,在Android中设置壁纸的方法有三种,分别是:

1、使用WallpaperManager的setResource(int ResourceID)方法

2、使用WallpaperManager的setBitmap(Bitmap bitmap)方法

3、重写ContextWrapper 类中提供的setWallpaper()

除此之外,我们还需要在应用程序中加入下列权限:

下面我们以此为基本方法,来实现Android中自带的壁纸应用。首先来看我的布局代码:

复制代码 代码如下:
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#000000"
    tools:context=".MainActivity" >
            android:id="@+id/ImageSwitcher"
        android:layout_width="fill_parent"
        android:layout_height="370dp">
   

            android:id="@+id/Gallery"
        android:layout_width="fill_parent"
        android:layout_height="80dp"
        android:layout_below="@+id/ImageSwitcher"  />