Android API Demos 2.2 SetWallpaper, Translucent和TranslucentBlur
2010-10-19 20:16:10 来源:WEB开发网import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
public class SetWallpaperActivity extends Activity {
final static private int[] mColors =
{Color.BLUE, Color.GREEN, Color.RED, Color.LTGRAY, Color.MAGENTA, Color.CYAN,
Color.YELLOW, Color.WHITE};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wallpaper_2);
// 1.获取与给定Context关联的WallpaperManager
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
// 2.获取当前系统壁纸
final Drawable wallpaperDrawable = wallpaperManager.getDrawable();
final ImageView imageView = (ImageView) findViewById(R.id.imageview);
imageView.setDrawingCacheEnabled(true);
imageView.setImageDrawable(wallpaperDrawable);
Button randomize = (Button) findViewById(R.id.randomize);
randomize.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
Xml代码
1. < style name="Theme.Translucent">
2. < item name="android:windowIsTranslucent">true< /item>
3. < item name="android:windowBackground">@drawable/translucent_background< /item>
4. < item name="android:windowNoTitle">true< /item>
5. < item name="android:colorForeground">#fff< /item>
6. < /style>
< style name="Theme.Translucent">
< item name="android:windowIsTranslucent">true< /item>
< item name="android:windowBackground">@drawable/translucent_background<
更多精彩
赞助商链接