在Android应用开发中,使用系统桌面背景作为应用的背景,需要把应用的背景设置为透明背景,然后设置窗口的属性为FLAG_SHOW_WALLPAPER即可显示背景。

修改AndroidManifest.xml文件里面activity属性:

<activity android:name=".WallPaperTest"

android:label="@string/app_name"

android:theme="@android:style/Theme.Translucent">

然后在使用的时候,在onCreate里面添加一个窗口属性

getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);

在背景拖动的时候主要是使用了WallpaperManager这个类的两个方法

public void setWallpaperOffsetSteps (float xStep, float yStep)

Since: API Level 7

For applications that use multiple virtual screens showing a wallpaper, specify the step size between virtual screens. For example, if the launcher has 3 virtual screens, it would specify an xStep of 0.5, since the X offset for those screens are 0.0, 0.5 and 1.0

Parameters
xStep The X offset delta from one screen to the next one
yStep The Y offset delta from one screen to the next one

public void setWallpaperOffsets (IBinder windowToken, float xOffset, float yOffset)

Since: API Level 5

Set the position of the current wallpaper within any larger space, when that wallpaper is visible behind the given window. The X and Y offsets are floating point numbers ranging from 0 to 1, representing where the wallpaper should be positioned within the screen space. These only make sense when the wallpaper is larger than the screen.

Parameters
windowToken The window who these offsets should be associated with, as returned by View.getWindowToken().
xOffset The offset along the X dimension, from 0 to 1.
yOffset

The offset along the Y dimension, from 0 to 1.

修改了之前ScrollLayout的类,让它支持显示系统背景,并且拖动的时候背景也跟着拖动,跟Launcher中的效果一致。。。
基本类文件ScrollLayout.java
  1. package com.yao_guet;
  2. import android.app.WallpaperManager;
  3. import android.content.Context;
  4. import android.os.IBinder;
  5. import android.util.AttributeSet;
  6. import android.util.Log;
  7. import android.view.MotionEvent;
  8. import android.view.VelocityTracker;
  9. import android.view.View;
  10. import android.view.ViewConfiguration;
  11. import android.view.ViewGroup;
  12. import android.widget.Scroller;
  13. /**
  14. * 仿Launcher中的WorkSapce,可以左右滑动切换屏幕的类,支持显示系统背景和滑动
  15. * @author Yao.GUET
  16. * blog: http://blog.csdn.net/Yao_GUET
  17. * date: 2011-05-04
  18. */
  19. public class ScrollLayout extends ViewGroup {
  20. private static final String TAG = "ScrollLayout";
  21. private Scroller mScroller;
  22. private VelocityTracker mVelocityTracker;
  23. private int mCurScreen;
  24. private int mDefaultScreen = 0;
  25. private static final int TOUCH_STATE_REST = 0;
  26. private static final int TOUCH_STATE_SCROLLING = 1;
  27. private static final int SNAP_VELOCITY = 600;
  28. private int mTouchState = TOUCH_STATE_REST;
  29. private int mTouchSlop;
  30. private float mLastMotionX;
  31. private float mLastMotionY;
  32. private WallpaperManager mWallpaperManager;
  33. private int mScrollX;
  34. public ScrollLayout(Context context, AttributeSet attrs) {
  35. this(context, attrs, 0);
  36. // TODO Auto-generated constructor stub
  37. }
  38. public ScrollLayout(Context context, AttributeSet attrs, int defStyle) {
  39. super(context, attrs, defStyle);
  40. // TODO Auto-generated constructor stub
  41. mWallpaperManager = WallpaperManager.getInstance(context);
  42. mScroller = new Scroller(context);
  43. mCurScreen = mDefaultScreen;
  44. mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
  45. }
  46. @Override
  47. protected void onLayout(boolean changed, int l, int t, int r, int b) {
  48. // TODO Auto-generated method stub
  49. Log.e(TAG, "onLayout");
  50. int childLeft = 0;
  51. final int childCount = getChildCount();
  52. for (int i=0; i<childCount; i++) {
  53. final View childView = getChildAt(i);
  54. if (childView.getVisibility() != View.GONE) {
  55. final int childWidth = childView.getMeasuredWidth();
  56. childView.layout(childLeft, 0,
  57. childLeft+childWidth, childView.getMeasuredHeight());
  58. childLeft += childWidth;
  59. }
  60. }
  61. updateWallpaperOffset();
  62. }
  63. @Override
  64. protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  65. Log.e(TAG, "onMeasure");
  66. super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  67. final int width = MeasureSpec.getSize(widthMeasureSpec);
  68. final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
  69. if (widthMode != MeasureSpec.EXACTLY) {
  70. throw new IllegalStateException("ScrollLayout only canmCurScreen run at EXACTLY mode!");
  71. }
  72. final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
  73. if (heightMode != MeasureSpec.EXACTLY) {
  74. throw new IllegalStateException("ScrollLayout only can run at EXACTLY mode!");
  75. }
  76. // The children are given the same width and height as the scrollLayout
  77. final int count = getChildCount();
  78. for (int i = 0; i < count; i++) {
  79. getChildAt(i).measure(widthMeasureSpec, heightMeasureSpec);
  80. }
  81. // Log.e(TAG, "moving to screen "+mCurScreen);
  82. scrollTo(mCurScreen * width, 0);
  83. }
  84. /**
  85. * According to the position of current layout
  86. * scroll to the destination page.
  87. */
  88. public void snapToDestination() {
  89. final int screenWidth = getWidth();
  90. final int destScreen = (getScrollX()+ screenWidth/2)/screenWidth;
  91. snapToScreen(destScreen);
  92. }
  93. public void snapToScreen(int whichScreen) {
  94. // get the valid layout page
  95. whichScreen = Math.max(0, Math.min(whichScreen, getChildCount()-1));
  96. if (getScrollX() != (whichScreen*getWidth())) {
  97. final int delta = whichScreen*getWidth()-getScrollX();
  98. mScroller.startScroll(getScrollX(), 0,
  99. delta, 0, Math.abs(delta)*2);
  100. mCurScreen = whichScreen;
  101. invalidate();       // Redraw the layout
  102. }
  103. }
  104. public void setToScreen(int whichScreen) {
  105. whichScreen = Math.max(0, Math.min(whichScreen, getChildCount()-1));
  106. mCurScreen = whichScreen;
  107. scrollTo(whichScreen*getWidth(), 0);
  108. }
  109. public int getCurScreen() {
  110. return mCurScreen;
  111. }
  112. @Override
  113. public void computeScroll() {
  114. // TODO Auto-generated method stub
  115. mScrollX = mScroller.getCurrX();
  116. if (mScroller.computeScrollOffset()) {
  117. scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
  118. updateWallpaperOffset();
  119. postInvalidate();
  120. }
  121. }
  122. @Override
  123. public boolean onTouchEvent(MotionEvent event) {
  124. // TODO Auto-generated method stub
  125. if (mVelocityTracker == null) {
  126. mVelocityTracker = VelocityTracker.obtain();
  127. }
  128. mVelocityTracker.addMovement(event);
  129. final int action = event.getAction();
  130. final float x = event.getX();
  131. final float y = event.getY();
  132. switch (action) {
  133. case MotionEvent.ACTION_DOWN:
  134. Log.e(TAG, "event down!");
  135. if (!mScroller.isFinished()){
  136. mScroller.abortAnimation();
  137. }
  138. mLastMotionX = x;
  139. break;
  140. case MotionEvent.ACTION_MOVE:
  141. int deltaX = (int)(mLastMotionX - x);
  142. mLastMotionX = x;
  143. scrollBy(deltaX, 0);
  144. updateWallpaperOffset();
  145. break;
  146. case MotionEvent.ACTION_UP:
  147. Log.e(TAG, "event : up");
  148. // if (mTouchState == TOUCH_STATE_SCROLLING) {
  149. final VelocityTracker velocityTracker = mVelocityTracker;
  150. velocityTracker.computeCurrentVelocity(1000);
  151. int velocityX = (int) velocityTracker.getXVelocity();
  152. Log.e(TAG, "velocityX:"+velocityX);
  153. if (velocityX > SNAP_VELOCITY && mCurScreen > 0) {
  154. // Fling enough to move left
  155. Log.e(TAG, "snap left");
  156. snapToScreen(mCurScreen - 1);
  157. } else if (velocityX < -SNAP_VELOCITY
  158. && mCurScreen < getChildCount() - 1) {
  159. // Fling enough to move right
  160. Log.e(TAG, "snap right");
  161. snapToScreen(mCurScreen + 1);
  162. } else {
  163. snapToDestination();
  164. }
  165. if (mVelocityTracker != null) {
  166. mVelocityTracker.recycle();
  167. mVelocityTracker = null;
  168. }
  169. // }
  170. mTouchState = TOUCH_STATE_REST;
  171. break;
  172. case MotionEvent.ACTION_CANCEL:
  173. mTouchState = TOUCH_STATE_REST;
  174. break;
  175. }
  176. return true;
  177. }
  178. @Override
  179. public boolean onInterceptTouchEvent(MotionEvent ev) {
  180. // TODO Auto-generated method stub
  181. Log.e(TAG, "onInterceptTouchEvent-slop:"+mTouchSlop);
  182. final int action = ev.getAction();
  183. if ((action == MotionEvent.ACTION_MOVE) &&
  184. (mTouchState != TOUCH_STATE_REST)) {
  185. return true;
  186. }
  187. final float x = ev.getX();
  188. final float y = ev.getY();
  189. switch (action) {
  190. case MotionEvent.ACTION_MOVE:
  191. final int xDiff = (int)Math.abs(mLastMotionX-x);
  192. if (xDiff>mTouchSlop) {
  193. mTouchState = TOUCH_STATE_SCROLLING;
  194. }
  195. break;
  196. case MotionEvent.ACTION_DOWN:
  197. mLastMotionX = x;
  198. mLastMotionY = y;
  199. mTouchState = mScroller.isFinished()? TOUCH_STATE_REST : TOUCH_STATE_SCROLLING;
  200. break;
  201. case MotionEvent.ACTION_CANCEL:
  202. case MotionEvent.ACTION_UP:
  203. mTouchState = TOUCH_STATE_REST;
  204. break;
  205. }
  206. return mTouchState != TOUCH_STATE_REST;
  207. }
  208. private void updateWallpaperOffset() {
  209. int scrollRange = getChildAt(getChildCount() - 1).getRight() - getWidth();
  210. IBinder token = getWindowToken();
  211. if (token != null) {
  212. mWallpaperManager.setWallpaperOffsetSteps(1.0f / (getChildCount() - 1), 0 );
  213. mWallpaperManager.setWallpaperOffsets(getWindowToken(),
  214. Math.max(0.f, Math.min(getScrollX()/(float)scrollRange, 1.f)), 0);
  215. }
  216. }
  217. }
  1. package com.yao_guet;
  2. import android.app.WallpaperManager;
  3. import android.content.Context;
  4. import android.os.IBinder;
  5. import android.util.AttributeSet;
  6. import android.util.Log;
  7. import android.view.MotionEvent;
  8. import android.view.VelocityTracker;
  9. import android.view.View;
  10. import android.view.ViewConfiguration;
  11. import android.view.ViewGroup;
  12. import android.widget.Scroller;
  13. /**
  14. * 仿Launcher中的WorkSapce,可以左右滑动切换屏幕的类,支持显示系统背景和滑动
  15. * @author Yao.GUET
  16. * blog: http://blog.csdn.net/Yao_GUET
  17. * date: 2011-05-04
  18. */
  19. public class ScrollLayout extends ViewGroup {
  20. private static final String TAG = "ScrollLayout";
  21. private Scroller mScroller;
  22. private VelocityTracker mVelocityTracker;
  23. private int mCurScreen;
  24. private int mDefaultScreen = 0;
  25. private static final int TOUCH_STATE_REST = 0;
  26. private static final int TOUCH_STATE_SCROLLING = 1;
  27. private static final int SNAP_VELOCITY = 600;
  28. private int mTouchState = TOUCH_STATE_REST;
  29. private int mTouchSlop;
  30. private float mLastMotionX;
  31. private float mLastMotionY;
  32. private WallpaperManager mWallpaperManager;
  33. private int mScrollX;
  34. public ScrollLayout(Context context, AttributeSet attrs) {
  35. this(context, attrs, 0);
  36. // TODO Auto-generated constructor stub
  37. }
  38. public ScrollLayout(Context context, AttributeSet attrs, int defStyle) {
  39. super(context, attrs, defStyle);
  40. // TODO Auto-generated constructor stub
  41. mWallpaperManager = WallpaperManager.getInstance(context);
  42. mScroller = new Scroller(context);
  43. mCurScreen = mDefaultScreen;
  44. mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
  45. }
  46. @Override
  47. protected void onLayout(boolean changed, int l, int t, int r, int b) {
  48. // TODO Auto-generated method stub
  49. Log.e(TAG, "onLayout");
  50. int childLeft = 0;
  51. final int childCount = getChildCount();
  52. for (int i=0; i<childCount; i++) {
  53. final View childView = getChildAt(i);
  54. if (childView.getVisibility() != View.GONE) {
  55. final int childWidth = childView.getMeasuredWidth();
  56. childView.layout(childLeft, 0,
  57. childLeft+childWidth, childView.getMeasuredHeight());
  58. childLeft += childWidth;
  59. }
  60. }
  61. updateWallpaperOffset();
  62. }
  63. @Override
  64. protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  65. Log.e(TAG, "onMeasure");
  66. super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  67. final int width = MeasureSpec.getSize(widthMeasureSpec);
  68. final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
  69. if (widthMode != MeasureSpec.EXACTLY) {
  70. throw new IllegalStateException("ScrollLayout only canmCurScreen run at EXACTLY mode!");
  71. }
  72. final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
  73. if (heightMode != MeasureSpec.EXACTLY) {
  74. throw new IllegalStateException("ScrollLayout only can run at EXACTLY mode!");
  75. }
  76. // The children are given the same width and height as the scrollLayout
  77. final int count = getChildCount();
  78. for (int i = 0; i < count; i++) {
  79. getChildAt(i).measure(widthMeasureSpec, heightMeasureSpec);
  80. }
  81. // Log.e(TAG, "moving to screen "+mCurScreen);
  82. scrollTo(mCurScreen * width, 0);
  83. }
  84. /**
  85. * According to the position of current layout
  86. * scroll to the destination page.
  87. */
  88. public void snapToDestination() {
  89. final int screenWidth = getWidth();
  90. final int destScreen = (getScrollX()+ screenWidth/2)/screenWidth;
  91. snapToScreen(destScreen);
  92. }
  93. public void snapToScreen(int whichScreen) {
  94. // get the valid layout page
  95. whichScreen = Math.max(0, Math.min(whichScreen, getChildCount()-1));
  96. if (getScrollX() != (whichScreen*getWidth())) {
  97. final int delta = whichScreen*getWidth()-getScrollX();
  98. mScroller.startScroll(getScrollX(), 0,
  99. delta, 0, Math.abs(delta)*2);
  100. mCurScreen = whichScreen;
  101. invalidate();       // Redraw the layout
  102. }
  103. }
  104. public void setToScreen(int whichScreen) {
  105. whichScreen = Math.max(0, Math.min(whichScreen, getChildCount()-1));
  106. mCurScreen = whichScreen;
  107. scrollTo(whichScreen*getWidth(), 0);
  108. }
  109. public int getCurScreen() {
  110. return mCurScreen;
  111. }
  112. @Override
  113. public void computeScroll() {
  114. // TODO Auto-generated method stub
  115. mScrollX = mScroller.getCurrX();
  116. if (mScroller.computeScrollOffset()) {
  117. scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
  118. updateWallpaperOffset();
  119. postInvalidate();
  120. }
  121. }
  122. @Override
  123. public boolean onTouchEvent(MotionEvent event) {
  124. // TODO Auto-generated method stub
  125. if (mVelocityTracker == null) {
  126. mVelocityTracker = VelocityTracker.obtain();
  127. }
  128. mVelocityTracker.addMovement(event);
  129. final int action = event.getAction();
  130. final float x = event.getX();
  131. final float y = event.getY();
  132. switch (action) {
  133. case MotionEvent.ACTION_DOWN:
  134. Log.e(TAG, "event down!");
  135. if (!mScroller.isFinished()){
  136. mScroller.abortAnimation();
  137. }
  138. mLastMotionX = x;
  139. break;
  140. case MotionEvent.ACTION_MOVE:
  141. int deltaX = (int)(mLastMotionX - x);
  142. mLastMotionX = x;
  143. scrollBy(deltaX, 0);
  144. updateWallpaperOffset();
  145. break;
  146. case MotionEvent.ACTION_UP:
  147. Log.e(TAG, "event : up");
  148. // if (mTouchState == TOUCH_STATE_SCROLLING) {
  149. final VelocityTracker velocityTracker = mVelocityTracker;
  150. velocityTracker.computeCurrentVelocity(1000);
  151. int velocityX = (int) velocityTracker.getXVelocity();
  152. Log.e(TAG, "velocityX:"+velocityX);
  153. if (velocityX > SNAP_VELOCITY && mCurScreen > 0) {
  154. // Fling enough to move left
  155. Log.e(TAG, "snap left");
  156. snapToScreen(mCurScreen - 1);
  157. } else if (velocityX < -SNAP_VELOCITY
  158. && mCurScreen < getChildCount() - 1) {
  159. // Fling enough to move right
  160. Log.e(TAG, "snap right");
  161. snapToScreen(mCurScreen + 1);
  162. } else {
  163. snapToDestination();
  164. }
  165. if (mVelocityTracker != null) {
  166. mVelocityTracker.recycle();
  167. mVelocityTracker = null;
  168. }
  169. // }
  170. mTouchState = TOUCH_STATE_REST;
  171. break;
  172. case MotionEvent.ACTION_CANCEL:
  173. mTouchState = TOUCH_STATE_REST;
  174. break;
  175. }
  176. return true;
  177. }
  178. @Override
  179. public boolean onInterceptTouchEvent(MotionEvent ev) {
  180. // TODO Auto-generated method stub
  181. Log.e(TAG, "onInterceptTouchEvent-slop:"+mTouchSlop);
  182. final int action = ev.getAction();
  183. if ((action == MotionEvent.ACTION_MOVE) &&
  184. (mTouchState != TOUCH_STATE_REST)) {
  185. return true;
  186. }
  187. final float x = ev.getX();
  188. final float y = ev.getY();
  189. switch (action) {
  190. case MotionEvent.ACTION_MOVE:
  191. final int xDiff = (int)Math.abs(mLastMotionX-x);
  192. if (xDiff>mTouchSlop) {
  193. mTouchState = TOUCH_STATE_SCROLLING;
  194. }
  195. break;
  196. case MotionEvent.ACTION_DOWN:
  197. mLastMotionX = x;
  198. mLastMotionY = y;
  199. mTouchState = mScroller.isFinished()? TOUCH_STATE_REST : TOUCH_STATE_SCROLLING;
  200. break;
  201. case MotionEvent.ACTION_CANCEL:
  202. case MotionEvent.ACTION_UP:
  203. mTouchState = TOUCH_STATE_REST;
  204. break;
  205. }
  206. return mTouchState != TOUCH_STATE_REST;
  207. }
  208. private void updateWallpaperOffset() {
  209. int scrollRange = getChildAt(getChildCount() - 1).getRight() - getWidth();
  210. IBinder token = getWindowToken();
  211. if (token != null) {
  212. mWallpaperManager.setWallpaperOffsetSteps(1.0f / (getChildCount() - 1), 0 );
  213. mWallpaperManager.setWallpaperOffsets(getWindowToken(),
  214. Math.max(0.f, Math.min(getScrollX()/(float)scrollRange, 1.f)), 0);
  215. }
  216. }
  217. }
测试代码WallPaperTest.java:
  1. package com.yao_guet;
  2. import android.app.Activity;
  3. import android.app.WallpaperManager;
  4. import android.content.Context;
  5. import android.os.Bundle;
  6. import android.view.KeyEvent;
  7. import android.view.Window;
  8. import android.view.WindowManager;
  9. public class WallPaperTest extends Activity {
  10. @Override
  11. protected void onCreate(Bundle savedInstanceState) {
  12. // TODO Auto-generated method stub
  13. super.onCreate(savedInstanceState);
  14. this.requestWindowFeature(Window.FEATURE_NO_TITLE);
  15. setContentView(R.layout.wallpaper_test);
  16. getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
  17. }
  18. @Override
  19. protected void onDestroy() {
  20. // TODO Auto-generated method stub
  21. super.onDestroy();
  22. }
  23. @Override
  24. public boolean onKeyDown(int keyCode, KeyEvent event) {
  25. // TODO Auto-generated method stub
  26. return super.onKeyDown(keyCode, event);
  27. }
  28. }
  1. package com.yao_guet;
  2. import android.app.Activity;
  3. import android.app.WallpaperManager;
  4. import android.content.Context;
  5. import android.os.Bundle;
  6. import android.view.KeyEvent;
  7. import android.view.Window;
  8. import android.view.WindowManager;
  9. public class WallPaperTest extends Activity {
  10. @Override
  11. protected void onCreate(Bundle savedInstanceState) {
  12. // TODO Auto-generated method stub
  13. super.onCreate(savedInstanceState);
  14. this.requestWindowFeature(Window.FEATURE_NO_TITLE);
  15. setContentView(R.layout.wallpaper_test);
  16. getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
  17. }
  18. @Override
  19. protected void onDestroy() {
  20. // TODO Auto-generated method stub
  21. super.onDestroy();
  22. }
  23. @Override
  24. public boolean onKeyDown(int keyCode, KeyEvent event) {
  25. // TODO Auto-generated method stub
  26. return super.onKeyDown(keyCode, event);
  27. }
  28. }
layout布局文件wallpaper_test.xml:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <com.sf.test.ScrollLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:id="@+id/WallPaperTest"
  5. android:layout_width="fill_parent"
  6. android:layout_height="fill_parent">
  7. <LinearLayout
  8. android:layout_width="fill_parent"
  9. android:layout_height="fill_parent">
  10. <TextView
  11. android:layout_width="fill_parent"
  12. android:layout_height="wrap_content"
  13. android:text="This is page 1" />
  14. </LinearLayout>
  15. <LinearLayout
  16. android:layout_width="fill_parent"
  17. android:layout_height="fill_parent">
  18. <TextView
  19. android:layout_width="fill_parent"
  20. android:layout_height="wrap_content"
  21. android:text="This is page 2" />
  22. </LinearLayout>
  23. <LinearLayout
  24. android:layout_width="fill_parent"
  25. android:layout_height="fill_parent">
  26. <TextView
  27. android:layout_width="fill_parent"
  28. android:layout_height="wrap_content"
  29. android:text="This is page 3" />
  30. </LinearLayout>
  31. <LinearLayout
  32. android:layout_width="fill_parent"
  33. android:layout_height="fill_parent">
  34. <TextView
  35. android:layout_width="fill_parent"
  36. android:layout_height="wrap_content"
  37. android:text="This is page 4" />
  38. </LinearLayout>
  39. <LinearLayout
  40. android:layout_width="fill_parent"
  41. android:layout_height="fill_parent">
  42. <TextView
  43. android:layout_width="fill_parent"
  44. android:layout_height="wrap_content"
  45. android:text="This is page 5" />
  46. </LinearLayout>
  47. <LinearLayout
  48. android:layout_width="fill_parent"
  49. android:layout_height="fill_parent">
  50. <TextView
  51. android:layout_width="fill_parent"
  52. android:layout_height="wrap_content"
  53. android:text="This is page 6" />
  54. </LinearLayout>
  55. <LinearLayout
  56. android:layout_width="fill_parent"
  57. android:layout_height="fill_parent">
  58. <TextView
  59. android:layout_width="fill_parent"
  60. android:layout_height="wrap_content"
  61. android:text="This is page 7" />
  62. </LinearLayout>
  63. </com.sf.test.ScrollLayout>
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <com.sf.test.ScrollLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:id="@+id/WallPaperTest"
  5. android:layout_width="fill_parent"
  6. android:layout_height="fill_parent">
  7. <LinearLayout
  8. android:layout_width="fill_parent"
  9. android:layout_height="fill_parent">
  10. <TextView
  11. android:layout_width="fill_parent"
  12. android:layout_height="wrap_content"
  13. android:text="This is page 1" />
  14. </LinearLayout>
  15. <LinearLayout
  16. android:layout_width="fill_parent"
  17. android:layout_height="fill_parent">
  18. <TextView
  19. android:layout_width="fill_parent"
  20. android:layout_height="wrap_content"
  21. android:text="This is page 2" />
  22. </LinearLayout>
  23. <LinearLayout
  24. android:layout_width="fill_parent"
  25. android:layout_height="fill_parent">
  26. <TextView
  27. android:layout_width="fill_parent"
  28. android:layout_height="wrap_content"
  29. android:text="This is page 3" />
  30. </LinearLayout>
  31. <LinearLayout
  32. android:layout_width="fill_parent"
  33. android:layout_height="fill_parent">
  34. <TextView
  35. android:layout_width="fill_parent"
  36. android:layout_height="wrap_content"
  37. android:text="This is page 4" />
  38. </LinearLayout>
  39. <LinearLayout
  40. android:layout_width="fill_parent"
  41. android:layout_height="fill_parent">
  42. <TextView
  43. android:layout_width="fill_parent"
  44. android:layout_height="wrap_content"
  45. android:text="This is page 5" />
  46. </LinearLayout>
  47. <LinearLayout
  48. android:layout_width="fill_parent"
  49. android:layout_height="fill_parent">
  50. <TextView
  51. android:layout_width="fill_parent"
  52. android:layout_height="wrap_content"
  53. android:text="This is page 6" />
  54. </LinearLayout>
  55. <LinearLayout
  56. android:layout_width="fill_parent"
  57. android:layout_height="fill_parent">
  58. <TextView
  59. android:layout_width="fill_parent"
  60. android:layout_height="wrap_content"
  61. android:text="This is page 7" />
  62. </LinearLayout>
  63. </com.sf.test.ScrollLayout>
然后记得修改AndroidManifest.xml文件。。。

<activity android:name=".WallPaperTest"

android:label="@string/app_name"

android:theme="@android:style/Theme.Translucent">

android 桌面透明的更多相关文章

  1. 桌面 透明 三角形 分层窗口 DX

    //桌面 透明 三角形 分层窗口 DX //IDirect3DSurface9 GetDC UpdateLayeredWindow #include <Windows.h> #includ ...

  2. Android -- 桌面悬浮,QQ管家火箭实现

    续上一篇博客<Android -- 桌面悬浮,仿360>,传送门:http://www.cnblogs.com/yydcdut/p/3909888.html,在此代码上继续添加实现. 比起 ...

  3. Android  PNG透明图片转JPG格式背景变黑

    Android  PNG透明图片转JPG格式背景变黑 在上传图片是,需要把PNG格式转换成JPG格式的,但是在遇上透明背景时,转过来就变成黑色底图了! 原因是PNG支持透明图而 JPG格式不支持透明底 ...

  4. Android设置透明、半透明等效果

    设置透明效果 大概有三种 1.用android系统的透明效果Java代码 android:background="@android:color/transparent"  例如 设 ...

  5. Android桌面小插件——Widget

    Android桌面小插件--Widget 效果图 实现 1. 创建Widget类 创建一个Widget类,并实现页面创建的时候,就实现显示时间 package com.kongqw.kqwwidget ...

  6. Android状态栏透明(沉浸式效果)

    Android状态栏透明(沉浸式效果) 默认效果 沉浸式效果 方式一 源码 下载地址(Android Studio工程):http://download.csdn.net/detail/q487880 ...

  7. 68.Android之透明状态栏

    转载:http://www.jianshu.com/p/2f17d0e7f6b0 Android开发中需要透明状态栏,注意:本文只适配Android4.4以上及5.0以上设备 概述 有时候我们想在 a ...

  8. Android课程---Android设置透明效果的三种方法(转)

    1.使用Android系统自带的透明效果资源 <Button  android:background="@android:color/transparent"/>   ...

  9. android桌面快捷方式跳转到指定activity

    AndroidManifest.xml 应用主入口配置: <activity android:name="com.*.cust.contacts.MainActivity" ...

随机推荐

  1. 使用Dotfunsctor

    设置Disable Control Flow.Disable Renaming.Disable String Encryption 为no,no为开启该功能 设置加密后输出的路i经 选择需要加密的ex ...

  2. 阿里云虚拟主机申请免费SSL证书并成功开通Https访问

    参考文档网址  https://baijiahao.baidu.com/s?id=1628343140232374972&wfr=spider&for=pc

  3. ANSYS热分析简介1

    目录 1. ANSYS热分析简介 1.1 传导 1.2 热载荷分类 1.2.1 载荷施加 1.3 热分析分类 1.3.1 稳态热分析 1.3.2 瞬态热分析 1.3.3 非线性分析综述 2. 热分析单 ...

  4. 杭电 1114 Piggy-Bank 完全背包问题

    Piggy-Bank Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  5. 杭电 2096 小明A+B

    小明A+B Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  6. December 21st, Week 51st Saturday, 2019

    May the odds be ever in your favor. 愿好运永远眷顾你. From The Hunger Games. May we all have good luck, and ...

  7. el-select 选项值动态更新的问题

      如果 类似 el-select 等表单元素绑定了 类似 a.b 之类的属性,而不是直接的一级属性的话,当这个属性发生更改的时候,它的显示效果可能不会动态地进行更新,这个时候需要使用 Vue.$se ...

  8. PAT A1034 Head Of Gang

    用并查集分割团伙,判断输出~ #include<bits/stdc++.h> using namespace std; ; },weight[maxn]; unordered_map< ...

  9. [转]轻松理解AOP思想(面向切面编程)

    原文链接 Spring是什么 先说一个Spring是什么吧,大家都是它是一个框架,但框架这个词对新手有点抽象,以致于越解释越模糊,不过它确实是个框架的,但那是从功能的角度来定义的,从本质意义上来讲,S ...

  10. 八 Spring的IOC的XML和注解的区别及其整合开发

    xml和注解的区别 xml和注解整合开发 注解:取消扫描配置开启注解配置 扫描:<context:component-scan base-package="" />  ...