在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. Python:函数基础

    概念 一段代码,集中到一起,起一个名字,下一次可以使用这个名字调用这个代码块,就是函数的功能 作用: 方便代码的重用 分解任务,简化程序逻辑 使代码更加模块化 函数的分类 内建函数 第三方函数 自定义 ...

  2. ArrayList,LinkedList,vector的区别

    1,Vector.ArrayList都是以类似数组的形式存储在内存中,LinkedList则以链表的形式进行存储. 2.List中的元素有序.允许有重复的元素,Set中的元素无序.不允许有重复元素. ...

  3. Flexconnect部署

    该记录主要用于针对于无线网络中Flexconnect的部署,可能涉及到的有Flexconnect中的组件,如何部署.(注意:在7.2版本以前,Flexconnect叫做HREAP),目前都称作为Fle ...

  4. WLC-Right to Use Licensing

    1.RTU的介绍 RTU licensing是没有和UDI(unique device identifier)或SN绑定的一种模型.在你接受了最终用户许可协议(EULA)后,使用RTU license ...

  5. Nexus-产品认识

    传统的思科数据中心网络架构也包括如下层级结构:    • 核心层(一般是Nexus 7K来充当)    • 汇聚层(一般也是Nexus 7K充当,可能存在2台,或4台的设备)    • 接入层(一般会 ...

  6. 基于three.js实现特定Div容器的粒子特效封装

    本文基于three.js实现特定容器的粒子特效效果,支持用户传入特定的dom对象以及粒子颜色. 效果图 移入库 <script src="jquery-1.11.3.min.js&qu ...

  7. 刷题17. Letter Combinations of a Phone Number

    一.题目说明 题目17. Letter Combinations of a Phone Number,题目给了下面一个图,输入一个字符串包括2-9,输出所有可能的字符组合. 如输入23所有可能的输出: ...

  8. Java连载66-数组的两种初始化方式

    一.数组 1.数组中存储元素的类型是统一的,每一个元素在内存中所占用的空间大小是相同的,知道数组的首元素的内存地址,要查找的元素只要知道下标,就可以快速的计算出偏移量,通过首元素内存地址加上偏移量,就 ...

  9. [Misc] ZSH 常用快捷键

    安装 zsh 终端执行 brew install zsh 终端执行 vim ~/.bash_profile 命令,打开 .bash_profile 文件 如果没有 vim,请自行安装 在打开的文件中, ...

  10. 查找字符串strscan

    ;Author : Bing ;Date : 1/10/2019;Usage: modify log drictory according to actual drictory fileopen fh ...