Words Don't say much
The implementation simply takes advantage of this clipdrawable
Clip.xml
<? XML version= "1.0" encoding= "Utf-8" ?> < 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 = "@drawable/clip" />
Mainactivity.java
PackageMdm.study.com.myresoucestudy;Importandroid.graphics.drawable.ClipDrawable;ImportAndroid.os.Bundle;ImportAndroid.os.Handler;ImportAndroid.os.Message;Importandroid.support.v7.app.AppCompatActivity;ImportAndroid.widget.ImageView;ImportJava.util.Timer;ImportJava.util.TimerTask; Public classMainactivityextendsappcompatactivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); //a slowly unfolding landscapeImageView Imgclip =(ImageView) Findviewbyid (R.id.imgclip); FinalClipdrawable clipdrawable =(clipdrawable) imgclip.getdrawable (); FinalHandler Handler =NewHandler () {@Override Public voidhandlemessage (Message msg) {if(Msg.what = = 0x123){ //range of clipdrawable values 0! 10000Clipdrawable.setlevel (Clipdrawable.getlevel () + 50); } } }; FinalTimer timer =NewTimer (); Timer.schedule (NewTimerTask () {@Override Public voidrun () {Message msg=Message.obtain (); Msg.what= 0x123; Handler.sendmessage (msg); //Cancel Timer if(Clipdrawable.getlevel () >= 10000) {timer.cancel (); } } },0,10); }}
It's simple.
Learn Android from scratch-the landscape that cilpdrawable slowly unfolds