在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. 5_6 团体队列(UVa540)<queue与STL其他容器的综合运用>

    先给出T个团体,并给出每个团体有多少人和每个人的编号,然后所有团体一起排队,排成一条大队列,排队的原则是,一个成员加入,如果这个成员所在的团体已经有人在排队了,那么他就加到他所在团体的最后面,而不是整 ...

  2. Python:re 模块

    re模块是python内置的正则表达式模块

  3. PyQt5操作SQLite数据库

    1.操作SQLite数据库import sysfrom PyQt5.QtSql import QSqlDatabase,QSqlQueryfrom PyQt5.QtCore import * def ...

  4. WORKDIR 指定工作目录 每一个 RUN 都是启动一个容器、执行命令、然后提交存储层文件变更

    WORKDIR 指定工作目录 格式为 WORKDIR <工作目录路径>. 使用 WORKDIR 指令可以来指定工作目录(或者称为当前目录),以后各层的当前目录就被改为指定的目录,如该目录不 ...

  5. border-1px的实现(stylus)如何在移动端设置1px的border

    在这里我只介绍下边框的实现: 当样式像素一定时,因手机有320px,640px等.各自的缩放比差异,所以设备显示像素就会有1Npx,2Npx.为保设计稿还原度,解决就是用media + scale. ...

  6. shell 脚本基础

    弱类型语言 bash 变量类型 本地变量 环境变量 局部变量 位置参数变量 特殊变量 运行 无执行权限 bash hello.sh 有执行权限 检查语法 bash -n user.sh 跟踪每一行的执 ...

  7. C++判断txt文件编码格式

    转载:https://blog.csdn.net/kikityan/article/details/89923808 记事本打开txt文件,然后另存,有四种编码格式可供选择,分别是:ANSI     ...

  8. jemter-plugins-maven dependency -WIiki用法配置介绍

    1.先介绍下jmeter 的maven中央仓库地址,有兴趣自己看下 https://mvnrepository.com/artifact/org.apache.jmeter 2.Wiki github ...

  9. Mysql基本用法-left join、right join、 inner join、子查询和join-02

    left join #左连接又叫外连接 left join 返回左表中所有记录和右表中连接字段相等的记录  test_user表 phpcvs表 SQL: select * from test_use ...

  10. 多项式输出 (0)<P2009_1>

    多项式输出 (poly.pas/c/cpp) [问题描述] 一元n次多项式可用如下的表达式表示: 其中,称为i次项,ai称为i次项的系数.给出一个一元多项式各项的次数和系数,请按照如下规定的格式要求输 ...