生也有涯,知也无涯。这篇文章主要讲述从零开始学android -- CilpDrawable 徐徐展开的风景相关的知识,希望能为你提供帮助。
话不多说上图
文章图片
实现简单利用了这个ClipDrawable
clip.xml
< ?xml version="1.0" encoding="utf-8"?> < clip xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/ic" android:clipOrientation="horizontal" android:gravity="left">
activity_main.xml
< ImageView android:id="@+id/imgclip" android:layout_width="200dp" android:layout_height="200dp" android:src="https://www.songbingjia.com/android/@drawable/clip"/>
MainActivity.java
package mdm.study.com.myresoucestudy; import android.graphics.drawable.ClipDrawable; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.support.v7.app.AppCompatActivity; import android.widget.ImageView; import java.util.Timer; import java.util.TimerTask; public class MainActivity extends AppCompatActivity {@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //徐徐展开的风景 ImageView imgClip = (ImageView) findViewById(R.id.imgclip); final ClipDrawable clipDrawable = (ClipDrawable) imgClip.getDrawable(); final Handler handler = new Handler(){ @Override public void handleMessage(Message msg) { if(msg.what == 0x123){ //clipDrawable值的范围0! 10000 clipDrawable.setLevel(clipDrawable.getLevel() + 50); } } }; final Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { Message msg = Message.obtain(); msg.what = 0x123; handler.sendMessage(msg); //取消定时器 if(clipDrawable.getLevel() > = 10000){ timer.cancel(); } } },0,10); } }
简单吧。
【从零开始学android -- CilpDrawable 徐徐展开的风景】
推荐阅读
- Intellij IDEA 去掉Mapper文件中的背景
- 如何获取Android唯一标识(唯一序列号)
- Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
- android studio - installation failed with message Invalid File
- Chrome调试模式获取App混合应用H5界面元素
- Android6.0------权限申请RxPermissions
- react-native之远程图片修改后APP不更新
- 本文教你电脑如何设置定时关机
- 本文教你笔记本电脑无线网卡修好