日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 默认站点!

默认站点

當前位置: 首頁 >

Android ViewAnimationUtils (动画) 的使用

發布時間:2023/11/27 28 豆豆
默认站点 收集整理的這篇文章主要介紹了 Android ViewAnimationUtils (动画) 的使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

先看下ViewAnimationUtils? 實現的幾個常見的效果圖如下:

?ViewAnimationUtils? 的作用:

設置剪切圓動畫的動畫制作器

一般的使用如下:

 Animator revealAnimator = ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius);

(1)view :view視圖視圖將被剪切到動畫圓上

(2)centerX:動畫圓中心的x坐標

(3)centerY:動畫圓中心的y坐標

(4)startRadius:動畫圓的起始半徑

(5)endRadius:動畫圓的結束半徑

代碼如下:

public class MainActivity extends AppCompatActivity {private ImageView imageView;@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);imageView = findViewById(R.id.img);// 左上角findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {Animator animator = ViewAnimationUtils.createCircularReveal(imageView, 0, 0, 0,(float) Math.hypot(imageView.getWidth(), imageView.getHeight()));animator.setDuration(3000);animator.start();// 監聽動畫,沒有需求可以不寫animator.addListener(new Animator.AnimatorListener() {@Overridepublic void onAnimationStart(Animator animation) {}@Overridepublic void onAnimationEnd(Animator animation) {}@Overridepublic void onAnimationCancel(Animator animation) {}@Overridepublic void onAnimationRepeat(Animator animation) {}});}});// 右上角findViewById(R.id.btn1).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {Animator animator = ViewAnimationUtils.createCircularReveal(imageView, imageView.getWidth(), 0, 0,(float) Math.hypot(imageView.getWidth(), imageView.getHeight()));animator.setDuration(3000);animator.start();}});// 左下角findViewById(R.id.btn4).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {Animator animator = ViewAnimationUtils.createCircularReveal(imageView,0, imageView.getHeight(), 0,(float) Math.hypot(imageView.getWidth(), imageView.getHeight()));animator.setDuration(3000);animator.start();}});// 右下角findViewById(R.id.btn5).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {Animator animator = ViewAnimationUtils.createCircularReveal(imageView,imageView.getWidth(), imageView.getHeight(), 0,(float) Math.hypot(imageView.getWidth(), imageView.getHeight()));animator.setDuration(3000);animator.start();}});findViewById(R.id.btn6).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {Animator animator = ViewAnimationUtils.createCircularReveal(imageView,imageView.getWidth()/2,0, 0,(float) Math.hypot(imageView.getWidth(), imageView.getHeight()));animator.setDuration(3000);animator.start();}});// 由內向外findViewById(R.id.btn2).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {Animator animator = ViewAnimationUtils.createCircularReveal(imageView, imageView.getWidth()/2,imageView.getHeight()/2,0, imageView.getWidth());animator.setDuration(3000);animator.start();}});//有外向內findViewById(R.id.btn3).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {Animator animator = ViewAnimationUtils.createCircularReveal(imageView, imageView.getWidth()/2,imageView.getHeight()/2,imageView.getWidth(), 0);animator.setDuration(3000);animator.start();}});}}

布局中的代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:context=".MainActivity"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><Buttonandroid:id="@+id/btn"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="左上角" /><Buttonandroid:id="@+id/btn1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="右上角" /><Buttonandroid:id="@+id/btn4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="左下角" /><Buttonandroid:id="@+id/btn5"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="右下角" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><Buttonandroid:id="@+id/btn2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="由內到外" /><Buttonandroid:id="@+id/btn3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="有外到內" /><Buttonandroid:id="@+id/btn6"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="頂部中間" /></LinearLayout><ImageViewandroid:id="@+id/img"android:layout_width="match_parent"android:layout_height="match_parent"android:scaleType="fitXY"android:src="@mipmap/girl" /></LinearLayout>

?

總結

以上是默认站点為你收集整理的Android ViewAnimationUtils (动画) 的使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得默认站点網站內容還不錯,歡迎將默认站点推薦給好友。