自定义一个网络加载框的utils
来源:互联网 发布:安卓好用的解压软件 编辑:程序博客网 时间:2024/06/07 23:17
- 该网络加载等待提示框是一个utils,该加载框是通过继承Dialog的方式实现,在使用时只需通过Dialog.Show()方法进行该控件的显示,通过Dialog. dismiss()方法进行控件的隐藏
- 该加载框无需修改其他布局
- 加载框的效果通过动画实现
–代码实现
1.首先创建一个类让该类继承Dialog
2.具体代码实现
public class LoadingDialog extends Dialog { public LoadingDialog(Context context) { super(context, R.style.loadingDialogStyle); } private LoadingDialog(Context context, int theme) { super(context, theme); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //加载布局 setContentView(R.layout.dialog_loading); ImageView imageView = (ImageView) findViewById(R.id.login_anim); //通过View的 getBackground得到AnimationDrawable对象 AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground(); //开启动画 animationDrawable.start(); }}
- 布局中的代码(res/layout/dialog_loading)
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:orientation="vertical" > <LinearLayout android:id="@+id/LinearLayout" android:layout_width="80dp" android:layout_height="80dp" android:background="@drawable/myprogress" android:gravity="center" android:orientation="vertical" > <ImageView android:id="@+id/login_anim" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@drawable/anim_login" /> <!--@drawable/anim_login为一个补间动画 -> </LinearLayout></LinearLayout>
- 动画效果实现(res/drawable/anim_login)
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false" > <!-- android:oneshot="false" 是否只播放一次 true 是 false 无限播放--> <!--android:drawable="@drawable/a" 图片路径--> <!-- android:duration="200" 事件--> <item android:drawable="@drawable/a" android:duration="200"/> <item android:drawable="@drawable/b" android:duration="200"/> <item android:drawable="@drawable/c" android:duration="200"/> <item android:drawable="@drawable/d" android:duration="200"/> <item android:drawable="@drawable/e" android:duration="200"/> <item android:drawable="@drawable/f" android:duration="200"/> <item android:drawable="@drawable/g" android:duration="200"/> <item android:drawable="@drawable/h" android:duration="200"/> <item android:drawable="@drawable/i" android:duration="200"/> <item android:drawable="@drawable/j" android:duration="200"/> <item android:drawable="@drawable/k" android:duration="200"/> <item android:drawable="@drawable/l" android:duration="200"/></animation-list>
图片就不上传了这里还可以进行其他动画的设置
0 0
- 自定义一个网络加载框的utils
- 自定义一个简单的可以加载网络图片的ImageView
- 一个自定义的加载器
- Android自定义网络数据加载等待框的简单封装
- Fresco加载图片Utils
- 网络判断utils
- 自定义网络加载视图NetworkImageView
- 自定义旋转的加载框
- 一个自定义的简单的类似于HUD的加载提示框
- 实现一个简单的自定义类加载器
- android一个BaseAdapter的使用(LayoutInflater加载自定义布局)
- Android自定义一个简单的动画加载页面
- 自定义View实战--实现一个清新美观的加载按钮
- 自定义一个类加载器
- 自定义一个类加载器
- 自定义一个类加载器
- 自定义一个类加载器
- Retrofit一个爽到HI的网络加载库
- iPhone历代产品,从3GS到7Plus详尽参数
- flask一次request请求过程 基于tag0.7
- 既不报错也不执行的问题——自己的解决心得
- C陷阱与缺陷(三)--语义陷阱1
- Android Studio使用之小插件
- 自定义一个网络加载框的utils
- Tensorflow学习
- 345. Reverse Vowels of a String
- Android面试题整理
- 利用委托两winform传实体
- Eclipse创建Maven Web项目
- 简明 Vim 练级攻略
- error LNK2019:无法解析的外部符号 _mysql_****
- C陷阱与缺陷(三)--语义陷阱2