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

Android API Demos 2.2 SetWallpaper, Translucent和TranslucentBlur

 2010-10-19 20:16:10 来源:WEB开发网   
核心提示:37.38. Button randomize = (Button) findViewById(R.id.randomize);39. randomize.setOnClickListener(new OnClickListener() {40. public void onClick(View view) {<

37.

38. Button randomize = (Button) findViewById(R.id.randomize);

39. randomize.setOnClickListener(new OnClickListener() {

40. public void onClick(View view) {< pre name="code" class="xml">< style name="Theme.Translucent">

41. < item name="android:windowIsTranslucent">true< /item>

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

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

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

45. < /style>< /pre>

46.

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

48. // 3.对壁纸进行修改

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

50. imageView.setImageDrawable(wallpaperDrawable);

51. imageView.invalidate();

52. }

53. });

54.

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

56. setWallpaper.setOnClickListener(new OnClickListener() {

57. public void onClick(View view) {

58. try {

59. // 4.设置壁纸

60. wallpaperManager.setBitmap(imageView.getDrawingCache());

61. finish();

62. } catch (IOException e) {

63. e.printStackTrace();

64. }

65. }

66. });

67. }

68. }

package com.example.android.apis.app;

// Need the following import to get access to the app resources, since this

// class is in a sub-package.

import com.example.android.apis.R;

import java.io.IOException;

import android.app.Activity;

import android.app.WallpaperManager;

import android.graphics.Color;

import android.graphics.PorterDuff;

上一页  1 2 3 4 5  下一页

Tags:Android API Demos

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接