一个常见的一个Dialog动画旋转效果
2017-06-13 15:03
239 查看
在我们进行一个网络访问的过程的时候,我们需要大概1到2秒钟的等待,所以我们给它一个动画效果,当网络访问成功的时候动画随之结束,给用户一个良好的体验效果.写了一个简单的Demo具体代码如下:
在跳转第二个页面的时候之前先出现一个动画效果,然后再跳转,以为Intent跳转非常快,所以显示效果不太明显,主要还是用于网络访问的操作等待时间时使用的效果
这是 Animal_Scale:
这样就会出现一个旋转的图案了.
public class MainActivity extends AppCompatActivity implements View.OnClickListener { private Button mBt; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mBt = (Button) findViewById(bt1); mBt.setOnClickListener(this); } @Override public void onClick(View v) { switch (v.getId()){ case R.id.bt1: Animal_Custom animal_custom = new Animal_Custom(this,null); animal_custom.show(); startActivity(new Intent(MainActivity.this,TwoActivity.class)); } } }
在跳转第二个页面的时候之前先出现一个动画效果,然后再跳转,以为Intent跳转非常快,所以显示效果不太明显,主要还是用于网络访问的操作等待时间时使用的效果
public class Animal_Custom extends Dialog { private String data_text; private Context mContext; private ImageView mIv_show; private RelativeLayout mRl_ahow; public Animal_Custom(Context context, String text) { super(context); this.data_text = text; this.mContext = context; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.animal_ 4000 layout); initView(); } private void initView() { mIv_show = (ImageView) findViewById(R.id.iv_show); mRl_ahow = (RelativeLayout) findViewById(R.id.rl_show); mIv_show.setBackgroundResource(R.drawable.Animal_Scale); AnimationDrawable background = (AnimationDrawable) mIv_show.getBackground(); background.start(); ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scaleAnimation.setDuration(200); mRl_ahow.startAnimation(scaleAnimation); Window window = this.getWindow(); WindowManager.LayoutParams params = this.getWindow().getAttributes(); window.setBackgroundDrawable(new BitmapDrawable()); //设置dialog的对话框透明程度背景 params.dimAmount = 0.5f; window.setAttributes(params); //点击以外的区域会不消失 setCancelable(false); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Animal_Custom.this.dismiss(); return false; }else { return super.onKeyDown(keyCode, event); } } }
这是 Animal_Scale:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@mipmap/r1" android:duration="50" /> <item android:drawable="@mipmap/r2" android:duration="50" /> <item android:drawable="@mipmap/r3" android:duration="50" /> <item android:drawable="@mipmap/r4" android:duration="50" /> <item android:drawable="@mipmap/r5" android:duration="50" /> <item android:drawable="@mipmap/r6" android:duration="50" /> <item android:drawable="@mipmap/r7" android:duration="50" /> <item android:drawable="@mipmap/r8" android:duration="50" /> <item android:drawable="@mipmap/r9" android:duration="50" /> <item android:drawable="@mipmap/r10" android:duration="50" /> <item android:drawable="@mipmap/r11" android:duration="50" /> <item android:drawable="@mipmap/r12" android:duration="50" /> <item android:drawable="@mipmap/r13" android:duration="50" /> <item android:drawable="@mipmap/r14" android:duration="50" /> <item android:drawable="@mipmap/r15" android:duration="50" /> <item android:drawable="@mipmap/r16" android:duration="50" /> </animation-list>
这样就会出现一个旋转的图案了.
相关文章推荐
- android 一个有漂亮动画效果的Dialog
- 做一个@font-face添加自己想要的字体样式,且用@keyframes做移动、旋转、阴影动画效果
- HTML5 Canvas旋转动画的2个代码例子(一个旋转的太极图效果)
- 一个带动画效果的颜色选择对话框控件AnimatedColorPickerDialog
- js 动画,一个图片旋转的动画
- iphone 一个强大的动画效果,真的很好,很强大哦
- Android 动画效果 --Animation 动画(讲解了所有的Android动画效果,是一个值得收藏的帖子)
- Android 中 画图与动画旋转效果(中级)
- 自己写一个非常不错的Jquery动画效果,flash,Get out!
- jquery动画3.创建一个带遮罩效果的图片走廊
- 一个帖子掌握android所有控件、ProgressBar 、Android 动画效果、SQLite、四大组件、Android多媒体
- 一个jquerydirection动画效果
- 一个帖子掌握android所有控件、ProgressBar 、Android 动画效果、SQLite、四大组件、Android多媒体(转
- Tab切换动画滑动效果的一个简单实现
- jquery动画 -- 2.元素坐标动画效果(创建一个图片走廊)
- andriod一个不错的启动菜单显示屏动画效果
- 一个可以实现 左右联动JTable 的完全Dialog 实现类似 Excel的冻结第一列 效果
- 写了一个android带动画翻页效果的程序
- 使用HTML5和jQuery插件Reel实现一个超酷的星际争霸2兵种动画360度预览效果
- Android应用开发——创建一个带动画效果的View