First of all, we should take a look at the case first: static graphs cannot show the effect. If you have used this software (zhake), all of us know that her background will change. do you think it is very fashionable? At least it is better than static (personal opinion ). in fact, the implementation is not complicated. If it is too child for game programmers to do it, I would like to explain that we should understand the programming thinking of games as well as how much we do in application, at least it is helpful for us to make applications. the following describes the implementation method. implementation principle: customizes A SurfaceView control. the constant onDraw makes the background dynamic. if you are not familiar with SurfaceView, please search for it online. here I will briefly introduce its functions: first, this control is a subclass of View. the advantage is that you can update the UI in the thread (non-UI thread. mySurfaceView. java [java] package com. jj. dynamic; import android. content. context; import Android. graphics. bitmap; import android. graphics. canvas; import android. graphics. color; import android. graphics. paint; import android. graphics. porterDuff; import android. util. attributeSet; import android. view. surfaceHolder; import android. view. surfaceView; import android. view. surfaceHolder. callback; public class MySurfaceView extends SurfaceView implements Callback, Runnable {private Context mCon Text; private SurfaceHolder surfaceHolder; private boolean flag = false; // thread ID private Bitmap bitmap_bg; // background image private float mSurfaceWindth, mSurfaceHeight; // screen width and height private int mBitposX; // The Position of the image is private Canvas mCanvas; private Thread thread; // The background movement status is private enum State {LEFT, RINGHT} // The default value is LEFT private State state = State. LEFT; private final int BITMAP_STEP = 1; // the movement of the background canvas. public MySurfaceView (C Ontext context, AttributeSet attrs) {super (context, attrs); flag = true; this. mContext = context; setFocusable (true); setFocusableInTouchMode (true); surfaceHolder = getHolder (); surfaceHolder. addCallback (this);}/***** to draw. */protected void onDraw () {drawBG (); updateBG ();}/***** update the background. */public void updateBG () {/** image scroll effect **/switch (state) {case LEFT: mBitposX-= BITMAP_STEP; // move the canvas LEFT to brea K; case RINGHT: mBitposX + = BITMAP_STEP; // shift break to the right of the canvas; default: break;} if (mBitposX <=-mSurfaceWindth/2) {state = State. RINGHT;} if (mBitposX> = 0) {state = State. LEFT ;}/ ***** draw background */public void drawBG () {mCanvas. drawColor (Color. TRANSPARENT, PorterDuff. mode. CLEAR); // CLEAR the screen. mCanvas. drawBitmap (bitmap_bg, mBitposX, 0, null); // draw the current screen background} @ Override public void run () {while (flag) {synch Ronized (surfaceHolder) {mCanvas = surfaceHolder. lockCanvas (); onDraw (); surfaceHolder. unlockCanvasAndPost (mCanvas); try {Thread. sleep (100);} catch (InterruptedException e) {e. printStackTrace () ;}}}@ Override public void surfaceCreated (SurfaceHolder holder) {mSurfaceWindth = getWidth (); mSurfaceHeight = getHeight (); int mWindth = (int) (mSurfaceWindth * 3/2);/***** scale the image to 3/2 times the screen size. */bi Tmap_bg = BitmapUtil. readBitmapById (mContext, R. drawable. hypers_bg, (int) mWindth, (int) mSurfaceHeight); thread = new Thread (this); thread. start () ;}@ Override public void surfaceChanged (SurfaceHolder holder, int format, int width, int height) {}@ Override public void surfaceDestroyed (SurfaceHolder holder) {flag = false;} The appeal code is quite simple. I will not introduce it too much. I believe everyone can understand it. the following is what we only need to do in Main. reference in xml. [java] <? Xml version = "1.0" encoding = "UTF-8"?> <Com. jj. dynamic. mySurfaceView xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "fill_parent" android: layout_height = "fill_parent"> </com. jj. dynamic. mySurfaceView> I will not display this. it is a time-changing background image. Next I will show you a small internal project I recently developed for the annual gala. (everything in it is moving .) I added a lot of animation effects. It took me a week to create this page. how about it? It looks good. in fact, I just want to explain something. we can fully integrate the game into our applications, so that we can get another scene. However, this will also have a negative impact, because they are all painted, so the workload will double. in short, it is good to develop based on your own needs. Next, let me upload and download apks. You can download the installation package and view the installation package. We can find the ghost .hypersparty.apk page again: I want to explain the EditText problem behind the password. To add it easily, we can directly solve it through the layout, now let's look at the layout file. I don't have the layout file code here, because I think it is better to understand this view, isn't it? If there is a lot more, I will post the layout file, it takes about half a day to read data. I have a strange question. take a look at the following picture: this picture shows the result of clicking the keyboard and letting the keyboard become a child (note: the keyboard can block the input box ). in fact, if you click edittext again, it is still in the original position, but the surfaceView is affected when being drawn. The reason is unknown. (next I will talk about a more strange problem. It's really one by one. I have a heart that wants to throw my cell phone. my testing machine is Huawei S8600 and android2.3. Then, when I tested it on the oppo mobile phone android4.0, I couldn't find the above bug picture. The mobile assistant showed that OK, but the mobile phone shows that it is a BUG, NND. At that time, it was depressing. No matter what it is, it is not the point .) the solution is very simple: we only need to execute this section in our activity and it will be OK. (Also applicable to custom dialog .) [java] getWindow (). setSoftInputMode (WindowManager. layoutParams. SOFT_INPUT_ADJUST_RESIZE | WindowManager. layoutParams. SOFT_INPUT_STATE_HIDDEN); some online users can configure it in the configuration file, but I am indifferent to the configuration. you can study it. In short, the Code solution is feasible.: Why is the password so high? This problem has not been solved. I hope you can tell me if you have any solutions. (If you try to solve this problem multiple times, I personally feel that the system uses edittext as the object and it will pop up, the distance in the middle is related to the location of edittext in the layout. If it is at the bottom, it is on the keyboard ). Some articles have said that getWindow (). setSoftInputMode (WindowManager. layoutParams. SOFT_INPUT_ADJUST_PAN); this sentence can be solved, but it is a pity that the trial is not satisfactory. in a word, I looked at the past and said it was just like this. I asked in the group yesterday that some friends proposed to create a transparent dialog and activity. Although this was not the case, but it is feasible. As long as you handle it well, it cannot be seen that they are not a layout. A simple note: in fact, you do not need to add the edittext control to surfaceView. For example, if you want to play a game, a sexy dialog will pop up. there is almost no need to load controls (especially edittext) in it. Even if there is a need, we can change our mindset to implement it.