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

Android API Demos 2.2 SetWallpaper, Translucent和TranslucentBlur

 2010-10-19 20:16:10 来源:WEB开发网   
核心提示:/item>< item name="android:windowNoTitle">true< /item>< item name="android:colorForeground">#fff< /item>< /sty
/item>

< item name="android:windowNoTitle">true< /item>

< item name="android:colorForeground">#fff< /item>

< /style>

int mColor = (int) Math.floor(Math.random() * mColors.length);

// 3.对壁纸进行修改

wallpaperDrawable.setColorFilter(mColors[mColor], PorterDuff.Mode.MULTIPLY);

imageView.setImageDrawable(wallpaperDrawable);

imageView.invalidate();

}

});

Button setWallpaper = (Button) findViewById(R.id.setwallpaper);

setWallpaper.setOnClickListener(new OnClickListener() {

public void onClick(View view) {

try {

// 4.设置壁纸

wallpaperManager.setBitmap(imageView.getDrawingCache());

finish();

} catch (IOException e) {

e.printStackTrace();

}

}

});

}

}

Translucent

设置window背景为半透明状态。在AndroidManifest.xml中为window配置半透明背景的theme。theme在xml文件中配置。

1. 通过继承android:style/Theme.Translucent实现。

Xml代码

1. < style name="Theme.Translucent" parent="android:style/Theme.Translucent">

2. < item name="android:windowBackground">@drawable/translucent_background< /item>

3. < item name="android:windowNoTitle">true< /item>

4. < item name="android:colorForeground">#fff< /item>

5. < /style>

< style name="Theme.Translucent" parent="android:style/Theme.Translucent">

< item name="android:windowBackground">@drawable/translucent_background< /item>

< item name="android:windowNoTitle">true< /item>

< item name="android:colorForeground">#fff< /item>

< /style>

2. 通过设置android:windowIsTranslucent为true实现。

上一页  1 2 3 4 5  下一页

Tags:Android API Demos

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