Android Studio實(shí)現(xiàn)補(bǔ)間動畫
本文實(shí)例為大家分享了Android Studio實(shí)現(xiàn)補(bǔ)間動畫的具體代碼,供大家參考,具體內(nèi)容如下
補(bǔ)間動畫是給出初始位置和結(jié)束位置,中間由系統(tǒng)自動補(bǔ)充的動畫
1、補(bǔ)間動畫的配置文件: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"(運(yùn)動時間)
android:toYScale="0.5"(結(jié)束大?。?
android:toXScale="0.5"
android:pivotY="50%"(運(yùn)動中心位置)
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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Android 讓自定義TextView的drawableLeft與文本一起居中
本文主要介紹Android 自定義控件TextView顯示居中問題,在開發(fā)過程中經(jīng)常會遇到控件的重寫,這里主要介紹TextView的drawableLeft與文本一起居中的問題2016-07-07
Android開發(fā)之CheckBox的簡單使用與監(jiān)聽功能示例
這篇文章主要介紹了Android開發(fā)之CheckBox的簡單使用與監(jiān)聽功能,結(jié)合簡單實(shí)例形式分析了Android使用CheckBox控件的布局與功能實(shí)現(xiàn)技巧,需要的朋友可以參考下2017-07-07
android使用intent傳遞參數(shù)實(shí)現(xiàn)乘法計算
這篇文章主要為大家詳細(xì)介紹了android使用intent傳遞參數(shù)實(shí)現(xiàn)乘法計算,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-04-04
詳解Android的OkHttp包編寫異步HTTP請求調(diào)用的方法
OkHttp支持Callback異步回調(diào)來實(shí)現(xiàn)線程的非阻塞,下面我們就來詳解Android的OkHttp包編寫異步HTTP請求調(diào)用的方法,需要的朋友可以參考下2016-07-07
android實(shí)現(xiàn)動態(tài)顯隱進(jìn)度條
這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)動態(tài)顯隱進(jìn)度條,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-07-07
Android 點(diǎn)擊editview以外位置實(shí)現(xiàn)隱藏輸入法
這篇文章主要介紹了Android 點(diǎn)擊editview以外位置實(shí)現(xiàn)隱藏輸入法的相關(guān)資料,需要的朋友可以參考下2017-06-06
Android中View.post和Handler.post的關(guān)系
這篇文章主要介紹了Android中View.post和Handler.post的關(guān)系,View.post和Handler.post是Android開發(fā)中經(jīng)常使用到的兩個”post“方法,關(guān)于兩者存在的區(qū)別與聯(lián)系,文章詳細(xì)分析需要的小伙伴可以參考一下2022-06-06

