• pushbox(5功能完善)


    实现屏幕的渐渐展开

    main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    
        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginTop="34dp"
            android:src="@drawable/gameclip" />
    
    </RelativeLayout>

    MainActivity.java

    package lesson.my.sudoku;
    
    import java.util.Timer;
    import java.util.TimerTask;
    
    import lession.my.sudoku.R;
    import android.app.Activity;
    import android.graphics.drawable.ClipDrawable;
    import android.os.Bundle;
    import android.os.Handler;
    import android.os.Message;
    import android.widget.ImageView;
    
    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            ImageView imageview = (ImageView) findViewById(R.id.imageView2);
            final ClipDrawable drawable = (ClipDrawable) imageview.getDrawable();
            drawable.setLevel(0);
            final Handler handler = new Handler() {
                //handler类用于与子线程的通信
                public void handleMessage(Message msg) {
                    if (msg.what == 0x1233) {
                        //每当受到子线程的信息,就让drawable变化
                        drawable.setLevel(drawable.getLevel() + 200);
                    }
                }
            };
            final Timer timer = new Timer();//timer计时器,休眠300ms
            timer.schedule(new TimerTask() {
                public void run() {
                    Message msg = new Message();
                    msg.what = 0x1233;
                    handler.sendMessage(msg);
                    if (drawable.getLevel() >= 10000) {
                        timer.cancel();
                    }
                }
            }, 0, 300);
        }
    }

  • 相关阅读:
    sql server 常用函数 及 方法
    jQuery校验 表单验证
    解决VS2012新建MVC4等项目时,收到加载程序集“NuGet.VisualStudio.Interop…”的错误
    CC++宏大全
    Linux在线文档
    x264编码详细文字全过程
    国外程序员推荐的免费编程书籍资源
    使用eclipse快捷键
    aria2下载工具
    Ubuntu 12.04 后的VMWare Share Fold
  • 原文地址:https://www.cnblogs.com/jianfengyun/p/3729682.html
Copyright © 2020-2023  润新知