Android实现多张图片合成加载动画_第1页
Android实现多张图片合成加载动画_第2页
Android实现多张图片合成加载动画_第3页
Android实现多张图片合成加载动画_第4页
Android实现多张图片合成加载动画_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

第Android实现多张图片合成加载动画本文实例为大家分享了Android实现多张图片合成加载动画的具体代码,供大家参考,具体内容如下

1、自定义ProgressDialog

publicclassMyProgressDialogextendsProgressDialog{

privateintprocressLoadRes;

privateImageViewmImageView;

privateAnimationDrawableanimationDrawable;

publicMyProgressDialog(Contextcontext,intprocressLoadRes){

super(context);

cressLoadRes=procressLoadRes;

}

publicMyProgressDialog(Contextcontext,inttheme,intprocressLoadRes){

super(context,theme);

cressLoadRes=procressLoadRes;

}

@Override

protectedvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.layout_progress);

mImageView=(ImageView)findViewById(R.id.image);

//设置动画背景

mImageView.setBackgroundResource(procressLoadRes);

//获取动画对象,必须在上一步之后

animationDrawable=(AnimationDrawable)mImageView.getBackground();

mImageView.post(newRunnable(){

@Override

publicvoidrun(){

//启动动画

animationDrawable.start();

}

});

}

}

2、MyProgressDialog对应的布局layout_progress.xml

xmlversion="1.0"encoding="utf-8"

LinearLayoutxmlns:android="/apk/res/android"

android:orientation="vertical"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:gravity="center"

android:background="@null"

ImageView

android:id="@+id/image"

android:layout_width="wrap_content"

android:layout_height="wrap_content"/

/LinearLayout

3、使用自定义的MyProgressDialog

publicclassMainActivityextendsAppCompatActivity{

privateButtonbutton;

privateMyProgressDialogprogressDialog;

@Override

protectedvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

button=(Button)findViewById(R.id.button);

//传入style和anim文件

progressDialog=newMyProgressDialog(this,R.style.dialog,R.anim.loading);

button.setOnClickListener(newView.OnClickListener(){

@Override

publicvoidonClick(Viewview){

progressDialog.show();

}

});

}

}

4、使用时需要一个style文件和一个anim文件

style.xml

stylename="dialog"parent="@android:style/Theme.Dialog"

!--边框--

itemname="android:windowFrame"@null/item

!--是否浮现在activity之上--

itemname="android:windowIsFloating"true/item

!--半透明--

itemname="android:windowIsTranslucent"false/item

!--无标题--

itemname="android:windowNoTitle"true/item

!--背景透明去掉背景色边框也就去掉了--

itemname="android:windowBackground"@color/transparent/item

!--模糊--

itemname="android:backgroundDimEnabled"false/item

/style

anim文件夹下的loading.xml文件

xmlversion="1.0"encoding="utf-8"

animation-listxmlns:android="/apk/res/android"

itemandroid:drawable="@mipmap/loading1"android:duration="100"/

itemandroid:drawable="@mipmap/loading2"android:duration="100"/

itemandroid:drawable="@mipmap/loading3"android:duration="100"/

itemandroid:drawable="@mipmap/loading4"android:duration="100"/

itemandroid:drawable="@mipmap/loading5"android:duration="100"/

itemandroid:drawable="@mipmap/loading6"android:duration="100"/

itemandroid:drawable="@mipmap/loading7"android:duration="100"/

itemandroid:drawable="@mipmap/loading8"android:duration="100"/

itemandroid:drawable="@mipmap/loading9"android:duration="100"/

itemandroid:drawable="@mipmap/loading10"android:duration="100"/

itemandroid:drawable="@mipmap/loading11"android:duration="100"/

itemandroid:drawable="@mipmap/loading12"android:duration="100"/

itemandroid:drawable="@mipmap/loading13"android:duration="100"/

itemandroid:drawable="@mipmap/loading14"android:duration="100"/

itemandroid:drawable="@mipmap/loading15"android:duration="100"/

itemandroid:drawable="@mipmap/loading16"android:duration="100"/

itemandroid:drawable="@mipmap/loading17"android:duration="100"/

itemandroid:drawable="@mipmap/loading18"android:duration="100"/

itemandroid:drawable="@mipmap/loading19"android:duration="100"/

itemandroid:drawable="@mipmap/loading20"android:duration="100"/

itemandroid:drawable="@mipmap/loading21"android:duration="100"/

itemandroid:drawable="@mipmap/loading22"android:duration="100"/

itemandroid:drawable="@mipmap/loading23"android:duration="100"/

itemandroid:drawable="@mipmap/loading24"android:duration="100"/

itemandroid:drawable="@mipmap/loading25"android:duration="100"/

itemandroid:drawable="@mipmap/loading26"android:duration="100"/

itemandroid:drawable="@mipmap/loading27"android:duration="100"/

itemandroid:drawable="@mipmap/loading30"android:duration="100"/

itemandroid:drawable="@mipmap/loading31"android:duration="100"/

itemandroid:drawable="@mipmap/loading32"android:duration="1

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论