Android Studio實現(xiàn)補間動畫
更新時間:2021年11月14日 15:47:00 作者:G.O.Y
這篇文章主要為大家詳細介紹了Android Studio實現(xiàn)補間動畫,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了Android Studio實現(xiàn)補間動畫的具體代碼,供大家參考,具體內(nèi)容如下
補間動畫是給出初始位置和結(jié)束位置,中間由系統(tǒng)自動補充的動畫
1、補間動畫的配置文件:scale.xml
2、布局文件:animal_patching.xml
3、main.java
sacle.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:duration="3000"(運動時間) android:toYScale="0.5"(結(jié)束大?。? android:toXScale="0.5" android:pivotY="50%"(運動中心位置) android:pivotX="50%" android:fromXScale="1"(初始大小) android:fromYScale="1"/> </set>
animal_patching
<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" xmlns:android="http://schemas.android.com/apk/res/android"> <ImageView android:id="@+id/image" android:background="@drawable/boy" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout>
main.java
package com.example.imageview; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ImageView; public class MainActivity<i> extends AppCompatActivity { /* private static final String TAG = "leo"; private NotificationManager manager; private Notification notification; private PopupWindow popupWindow; //創(chuàng)建一個數(shù)組,內(nèi)部元素為Bean類型; private List<Bean> data = new ArrayList<>(); */ private boolean flag = true; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.cartoon_patching); ImageView imageView = findViewById(R.id.image); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //透明度*********************************** // Animation animation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.alpad_1); // imageView.startAnimation(animation); //旋轉(zhuǎn)************************************ // Animation animation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.rotate); // imageView.startAnimation(animation); //大小縮放********************************** // Animation animation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.scale); // imageView.startAnimation(animation); //平移************************************ Animation animation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.translate); imageView.startAnimation(animation); } }); }
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
Java語言讀取配置文件config.properties的方法講解
今天小編就為大家分享一篇關于Java語言讀取配置文件config.properties的方法講解,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-03-03Android 中TextView中跑馬燈效果的實現(xiàn)方法
這篇文章主要介紹了Android 中TextView中跑馬燈效果的實現(xiàn)方法,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-02-02Android使用ViewDragHelper實現(xiàn)QQ聊天氣泡拖動效果
這篇文章主要為大家詳細介紹了Android使用ViewDragHelper實現(xiàn)QQ聊天氣泡拖動效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-01-01