WEB开发网
开发学院手机开发Android 开发 Android API Demos 2.2 SetWallpaper, Translucen... 阅读

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.OnClickLi

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<

上一页  1 2 3 4 5  下一页

Tags:Android API Demos

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接