日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內(nèi)最全I(xiàn)T社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > php開源 > 綜合技術(shù) > Android帶動畫效果的彈窗

Android帶動畫效果的彈窗

來源:程序員人生   發(fā)布時間:2015-03-19 08:30:19 閱讀次數(shù):5084次
在網(wǎng)絡(luò)加載數(shù)據(jù)的時候通常需要很多時間,這個時候程序里面常常需要寫1個提示正在加載數(shù)據(jù)的彈窗,這篇文章用兩種方式實現(xiàn)帶動畫效果的Dialog:幀動畫實現(xiàn)和GIF動態(tài)圖實現(xiàn),它們都能到達(dá)動畫的效果
第1種、幀動畫實現(xiàn)
自定義1個Dialog,先看1下布局文件dialog_animation.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" android:paddingBottom="20dp" android:paddingLeft="80dp" android:paddingRight="80dp" android:paddingTop="20dp" > <ImageView android:id="@+id/dialog_animation_img" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/dialog_animation_txt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:gravity="center" android:text="正在加載數(shù)據(jù)。。。" android:textColor="@android:color/black" android:textSize="16sp" /> </LinearLayout>
ImageView用來顯示動畫,TextView用于提示用戶我們正在加載數(shù)據(jù)
public static Dialog createAnimationDailog(final Context context) { final Dialog dialog = new Dialog(context, R.style.dialog); dialog.setContentView(R.layout.dialog_animation); ImageView animationView = (ImageView) dialog .findViewById(R.id.dialog_animation_img); animationView.setBackgroundResource(R.drawable.animation_dialog); AnimationDrawable animationDrawable = (AnimationDrawable) animationView .getBackground(); animationDrawable.start(); final TextView textView = (TextView) dialog .findViewById(R.id.dialog_animation_txt); Animation animation = AnimationUtils.loadAnimation(context, R.anim.animation_dialog_txt); // animation的循環(huán)播放模式不起作用,只能手動的在動畫播放完以后再播放1次 animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { Animation anim = AnimationUtils.loadAnimation(context, R.anim.animation_dialog_txt); textView.startAnimation(anim); anim.setAnimationListener(this); } @Override public void onAnimationRepeat(Animation arg0) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation arg0) { // TODO Auto-generated method stub } }); // 綁定動畫 textView.startAnimation(animation); return dialog; }
ImageView中的幀動畫文件,很簡單的,就3張圖片順序播放。新建res/drawable/animation_dialog.xml
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false" > <item android:drawable="@drawable/girl1" android:duration="100"/> <item android:drawable="@drawable/girl2" android:duration="100"/> <item android:drawable="@drawable/girl3" android:duration="100"/> </animation-list>
TextView使用的補(bǔ)間動畫文件。新建res/anim/animation_dialog_txt.xml
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillBefore="true" android:fillEnabled="true" android:repeatMode="restart" > <translate android:duration="1000" android:fromXDelta="⑵0%" android:interpolator="@android:anim/accelerate_interpolator" android:toXDelta="0%" /> <translate android:duration="1000" android:fromXDelta="0%" android:interpolator="@android:anim/decelerate_interpolator" android:toXDelta="20%" /> <alpha android:duration="1000" android:fromAlpha="0.0" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:toAlpha="1" /> <alpha android:duration="200" android:fromAlpha="1" android:interpolator="@android:anim/decelerate_interpolator" android:toAlpha="0.8" /> </set>

效果圖

截屏效果太差,實際動畫是很流暢的,相信我。

第2種、GIF動態(tài)圖實現(xiàn)
這類是通過播放GIF動態(tài)圖來到達(dá)動畫效果。
首先這需要1個第3方的jar包,GifView.jar,將其下載以后導(dǎo)入項目
新建布局文件dialog_gif.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" android:paddingBottom="20dp" android:paddingLeft="80dp" android:paddingRight="80dp" android:paddingTop="20dp" > <com.ant.liao.GifView android:id="@+id/dialog_gifView" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/dialog_gif_txt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:gravity="center" android:text="正在加載數(shù)據(jù)。。。" android:textColor="@android:color/black" android:textSize="16sp" /> </LinearLayout>
public static Dialog createGIFDialog(final Context context) { final Dialog dialog = new Dialog(context, R.style.dialog); dialog.setContentView(R.layout.dialog_gif); GifView gifView = (GifView) dialog.findViewById(R.id.dialog_gifView); gifView.setGifImage(R.drawable.ride); gifView.showAnimation(); final TextView textView = (TextView) dialog .findViewById(R.id.dialog_gif_txt); Animation animation = AnimationUtils.loadAnimation(context, R.anim.animation_dialog_txt); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { Animation anim = AnimationUtils.loadAnimation(context, R.anim.animation_dialog_txt); textView.startAnimation(anim); anim.setAnimationListener(this); } @Override public void onAnimationRepeat(Animation arg0) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation arg0) { // TODO Auto-generated method stub } }); // 綁定動畫 textView.startAnimation(animation); return dialog; }

效果圖


源碼下載







生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 成年人免费视频观看 | 日韩中文字幕在线视频 | 国产一区在线免费观看 | 亚洲欧美国产一区二区三区 | 精品久久久久久综合日本 | 中文字幕影院 | 午夜视频在线免费观看 | 国产一区二区三区高清 | 亚洲在看 | 毛片毛 | 国产一区二区三区在线观看网站 | 日韩精品1区2区3区 精品视频首页 | 日本久久久久久久久 | 国产免费小视频 | 99re在线免费视频 | 国产免费一区二区 | 欧美日韩在线一区二区三区 | 毛片三级 | 爱爱免费视频网站 | 精品久久久久久亚洲综合网 | 国产成人av一区二区三区 | 在线国产视频 | 亚洲免费福利视频 | 日韩一级片一区二区 | 91国内精品久久 | 国产二三区 | 视频在线观看国产 | 国产精品国产成人国产三级 | 国产精品亚洲一区二区三区在线 | 日韩综合在线 | 成人在线免费视频 | 国产伦精品一区二区三区免费视频 | 国产精品久久久久久久久久东京 | 国产成人精品综合 | 黄色片网站在线观看 | 国产午夜亚洲精品理论片色戒 | 日韩av电影在线播放 | 久久国产成人精品 | 欧美一级免费大片 | 七七婷婷婷婷精品国产 | 一区不卡 |