在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">

最新文章

  1. 最短路径——Floyd-Warshall算法
  2. [原创]Oracle 12c 抢先安装手迹
  3. Java关键字——super
  4. java跳出外部循环
  5. 2016.7.9 计算机网络复习要点第四章之虚拟专用网VPN和网络地址转换NAT
  6. NoSQL系列:选择合适的数据库
  7. angularJs编写多指令的情况
  8. openlayers加载地图没有图片时有红叉的解决方法
  9. Android ViewDragHelper源码解析
  10. echarts演示笔记
  11. Visual Studio2017数据库架构比较
  12. 什么是PMI
  13. vue2 watch引用类型 失败原因
  14. Python基础-week04
  15. Kotlin入门(25)共享参数模板
  16. cf1110F 离线+树上操作+线段树区间更新
  17. Golang获得执行文件的当前路径
  18. JSONObject.parseObject(jsonStr);和JSONObject.fromObject(jsonStr);
  19. linux文件系统比较
  20. e672. 缩放,剪取,移动,翻转缓冲图像

热门文章

  1. Ubuntu python3 与 python2 的 pip调用
  2. socket 多连接
  3. PTA的Python练习题(十四)
  4. python学习 —— 获取系统运行情况信息并在Linux下设置定时运行python脚本
  5. 工具 - gravatar保存头像
  6. 神奇的 SQL 之 联表细节 → MySQL JOIN 的执行过程
  7. UIImage点九图(让image不变形、只拉伸中间部分)
  8. python 的参数总结
  9. VSCode 出现错误 System.IO.IOException: The configured user limit (128) on the number of inotify instances has been reached.
  10. day11 作业