Android開發(fā)簡單實現搖動動畫的方法
本文實例講述了Android開發(fā)簡單實現搖動動畫的方法。分享給大家供大家參考,具體如下:
1、先創(chuàng)建shake.xml
<?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="700" android:fromXDelta="0.0" android:interpolator="@anim/cycle" android:toXDelta="15.0" />
2、創(chuàng)建cycle.xml
<?xml version="1.0" encoding="utf-8"?> <cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="4.0" />
3、使用方式
Animation animation = AnimationUtils.loadAnimation(this, R.anim.shake); animation.setDuration(1000); animation.setRepeatMode(Animation.INFINITE); iv.startAnimation(animation);
更多關于Android相關內容感興趣的讀者可查看本站專題:《Android開發(fā)動畫技巧匯總》、《Android開發(fā)入門與進階教程》、《Android視圖View技巧總結》、《Android編程之activity操作技巧總結》、《Android文件操作技巧匯總》、《Android資源操作技巧匯總》及《Android控件用法總結》
希望本文所述對大家Android程序設計有所幫助。
相關文章
Android DaggerActivityComponent錯誤解決辦法詳解
這篇文章主要介紹了Android DaggerActivityComponent錯誤解決的相關資料,需要的朋友可以參考下2017-05-05Android HelloChart開源庫圖表之折線圖的實例代碼
這篇文章主要介紹了Android HelloChart開源庫圖表之折線圖的實例代碼,具有很好的參考價值,希望對大家有所幫助,一起跟隨小編過來看看吧2018-05-05Flutter?WebView?預加載實現方法(Http?Server)
這篇文章主要介紹了Flutter?WebView?預加載實現方法,包括資源的配置,資源的下載和存儲,版本的管理,如何根據實際url獲取對應HttpServer?bind的url等,需要的朋友可以參考下2022-05-05