Android 動(dòng)畫之AlphaAnimation應(yīng)用詳解
AlphaAnimation 透明度動(dòng)畫效果
ScaleAnimation 縮放動(dòng)畫效果
TranslateAnimation 位移動(dòng)畫效果
RotateAnimation 旋轉(zhuǎn)動(dòng)畫效果
本節(jié)講解AlphaAnimation 動(dòng)畫,窗口的動(dòng)畫效果,淡入淡出什么的,有些游戲的歡迎動(dòng)畫,logo的淡入淡出效果就使用AlphaAnimation。
直接看代碼:
public class MainActivity extends Activity {
ImageView image;
Button start;
Button cancel;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image = (ImageView) findViewById(R.id.main_img);
start = (Button) findViewById(R.id.main_start);
cancel = (Button) findViewById(R.id.main_cancel);
/** 設(shè)置透明度漸變動(dòng)畫 */
final AlphaAnimation animation = new AlphaAnimation(1, 0);
animation.setDuration(2000);//設(shè)置動(dòng)畫持續(xù)時(shí)間
/** 常用方法 */
//animation.setRepeatCount(int repeatCount);//設(shè)置重復(fù)次數(shù)
//animation.setFillAfter(boolean);//動(dòng)畫執(zhí)行完后是否停留在執(zhí)行完的狀態(tài)
//animation.setStartOffset(long startOffset);//執(zhí)行前的等待時(shí)間
start.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
image.setAnimation(animation);
/** 開始動(dòng)畫 */
animation.startNow();
}
});
cancel.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
/** 結(jié)束動(dòng)畫 */
animation.cancel();
}
});
}
}<SPAN style="COLOR: #333333; FONT-FAMILY: Microsoft YaHei"><SPAN style="FONT-SIZE: 14px; LINE-HEIGHT: 26px">
</SPAN></SPAN>
效果:

- Android Tween動(dòng)畫之RotateAnimation實(shí)現(xiàn)圖片不停旋轉(zhuǎn)效果實(shí)例介紹
- Android 動(dòng)畫之RotateAnimation應(yīng)用詳解
- Android 動(dòng)畫之TranslateAnimation應(yīng)用詳解
- Android 動(dòng)畫之ScaleAnimation應(yīng)用詳解
- 三款A(yù)ndroid炫酷Loading動(dòng)畫組件推薦
- Android實(shí)現(xiàn)Activity界面切換添加動(dòng)畫特效的方法
- Android 使用XML做動(dòng)畫UI的深入解析
- Android啟動(dòng)畫面的實(shí)現(xiàn)方法
- Android 吸入動(dòng)畫效果實(shí)現(xiàn)分解
- Android動(dòng)畫之3D翻轉(zhuǎn)效果實(shí)現(xiàn)函數(shù)分析
- Android編程實(shí)現(xiàn)RotateAnimation設(shè)置中心點(diǎn)旋轉(zhuǎn)動(dòng)畫效果
相關(guān)文章
解決Android 6.0獲取wifi Mac地址為02:00:00:00:00:00問題
這篇文章主要介紹了Android 6.0獲取wifi Mac地址為02:00:00:00:00:00的解決方法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-11-11Android 滑動(dòng)監(jiān)聽的實(shí)例詳解
這篇文章主要介紹了Android 滑動(dòng)監(jiān)聽的實(shí)例詳解的相關(guān)資料,希望通過本能幫助到大家,需要的朋友可以參考下2017-09-09Android編程實(shí)現(xiàn)二級(jí)下拉菜單及快速搜索的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)二級(jí)下拉菜單及快速搜索的方法,以實(shí)例形式較為詳細(xì)的分析了Android實(shí)現(xiàn)二級(jí)下拉菜單及快速搜索的布局與功能實(shí)現(xiàn)技巧,需要的朋友可以參考下2015-11-11Android實(shí)現(xiàn)將View保存成Bitmap的方法
這篇文章主要介紹了Android實(shí)現(xiàn)將View保存成Bitmap的方法,涉及Android畫布Canvas、位圖bitmap及View的相關(guān)使用技巧,需要的朋友可以參考下2016-06-06Android實(shí)現(xiàn)雙層ViewPager嵌套
這篇文章主要介紹了Android實(shí)現(xiàn)雙層ViewPager嵌套,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-04-04詳解Android開發(fā)之MP4文件轉(zhuǎn)GIF文件
這篇文章介紹的是將錄下來的視頻選取一小段轉(zhuǎn)為 GIF 文件,不僅時(shí)間段可以手動(dòng)選取,而且還需要支持截取視頻的局部區(qū)域轉(zhuǎn)為 GIF,網(wǎng)上調(diào)研了一下技術(shù)方案,覺得還是有必要把實(shí)現(xiàn)過程拿出來分享下,有需要的可以直接拿過去用。下面來一起看看。2016-08-08解決Android Studio Gradle Metadata特別慢的問題
這篇文章主要介紹了解決Android Studio Gradle Metadata特別慢的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-03-03Android動(dòng)態(tài)添加menu菜單的簡(jiǎn)單方法
Android動(dòng)態(tài)添加menu菜單的簡(jiǎn)單方法,需要的朋友可以參考一下2013-06-06Android實(shí)現(xiàn)RecyclerView嵌套流式布局的詳細(xì)過程
最近在做需求的時(shí)候,碰到有各種篩選項(xiàng)的界面,下面這篇文章主要給大家介紹了關(guān)于Android實(shí)現(xiàn)RecyclerView嵌套流式布局的詳細(xì)過程,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-12-12Android Studio實(shí)現(xiàn)補(bǔ)間動(dòng)畫
這篇文章主要為大家詳細(xì)介紹了Android Studio實(shí)現(xiàn)補(bǔ)間動(dòng)畫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-11-11