码迷,mamicode.com
首页 > 其他好文 > 详细

pushbox(5功能完善)

时间:2014-05-15 21:34:37      阅读:264      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   class   code   java   

实现屏幕的渐渐展开

main.xml

bubuko.com,布布扣
<?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>
bubuko.com,布布扣

MainActivity.java

bubuko.com,布布扣
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);
    }
}
bubuko.com,布布扣

bubuko.com,布布扣

pushbox(5功能完善),布布扣,bubuko.com

pushbox(5功能完善)

标签:android   style   blog   class   code   java   

原文地址:http://www.cnblogs.com/jianfengyun/p/3729682.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!