在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. windows 配置hadoop环境

    在idea运行spark程序的时候报错:java.io.IOException: Could not locate executable null\bin\winutils.exe in the Ha ...

  2. 【转载】IntelliJ IDEA配置JUnit进行单元测试

    前提条件 安装JDK,并配置好环境变量 工程已解决JUnit依赖关系(pom.xml) IDEA中JUnit配置 IDEA自带一个JUnit插件,打开Settings窗口搜索junit,如图:   图 ...

  3. 通过js检测浏览器支持的字体,从而显示支持的字体,让用户选择。

    http://www.zhangxinxu.com/wordpress/2018/02/js-detect-suppot-font-family/ 本文根据张鑫旭文章. 字体函数: var dataF ...

  4. python输出颜色与样式的方法

    一.输出颜色与样式的方法 上次遇到这个问题就想写下来,其实当时我也不怎么会,老师说这个东西不需要理解,只需要死记硬背,写的多了就记住了,所以今天搜集了几篇文章,加上自己的理解,写下了这篇python ...

  5. [Write-up]-Trollcave: 1.2

    关于 下载地址:点我 Flag:root/flag.txt 哔哩哔哩:视频 信息收集 不知道VM虚拟机怎么啦,导入镜像后,用Nmap扫了,发现不了主机.所以这次用了VBox. vboxnet0的IP为 ...

  6. 数字反转(0)<P2011_1>

    数字反转  (reverse.cpp/c/pas) [问题描述] 给定一个整数,请将该数各个位上数字反转得到一个新数.新数也应满足整数的常见形 式,即除非给定的原数为零,否则反转后得到的新数的最高位数 ...

  7. select模块

    select模块 1.      select模块 源:select.py This module provides access to the select() and poll() functio ...

  8. Java基础 -5.2

    方法重载 当方法名称相同,参数的类型或者个数不同的时候 就会称为方法重载. public static void main(String[] args) { System.out.println(ad ...

  9. sqlalchemy 连接mysql8.0报 RuntimeError: cryptograpy si requeired for sha256_password 错误

    cryptography is required for sha256_password or caching_sha2_password 需要cryptography模块的支持才能连接需要sha25 ...

  10. Servlet简单的登陆窗口

    web.xml配置: jsp代码: 注意:action书写的是为这次登陆做处理类的别名,method就是请求的方式 Get请求方式没有请求实体 //如果只是看效果就光写一下service方法就行了 p ...