首页 > 代码库 > pushbox(5功能完善)
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); } }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。