自定义对话框之动画效果
2014-11-06 18:17
218 查看
//参考博客
http://blog.csdn.net/dyllove98/article/details/8841602
//动画效果res/anim/enter.xml
res/anim/out.xml
android:pivotX="50%"
android:pivotY="50%"
以中心为缩放点
//res/value.xml
http://blog.csdn.net/dyllove98/article/details/8841602
//动画效果res/anim/enter.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <alpha android:duration="500" android:fromAlpha="0.1" android:toAlpha="1.0" /> <scale android:duration="500" android:toXScale="1" android:fromXScale="0" android:toYScale="1" android:fromYScale="0" android:pivotX="50%" android:pivotY="50%"/> </set>
res/anim/out.xml
<set xmlns:android="http://schemas.android.com/apk/res/android"> <alpha android:duration="500" android:fromAlpha="1.0" android:toAlpha="0.1" /> <scale android:duration="500" android:toXScale="0" android:fromXScale="1" android:toYScale="0" android:fromYScale="1" android:pivotX="50%" android:pivotY="50%"/> </set>
android:pivotX="50%"
android:pivotY="50%"
以中心为缩放点
//res/value.xml
<style name="style_dialog" parent="@android:style/Theme.Dialog"> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@drawable/bg</item> <item name="android:backgroundDimEnabled">false</item> <item name="android:windowIsTranslucent">false</item> <item name="android:backgroundDimAmount">0.1</item> <item name="android:windowAnimationStyle">@style/dialog_animation</item> </style> <style name="dialog_animation" > <item name="android:windowEnterAnimation">@anim/enter</item> <item name="android:windowExitAnimation">@anim/out</item> </style>//主要代码
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button=(Button)this.findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { verifyDialog(); } }); } private void verifyDialog() { final Dialog dialog = new Dialog(MainActivity.this, R.style.style_dialog);//可是只对话框的样式 dialog.setContentView(R.layout.img); dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(true); dialog.show(); } }//效果:进入时由中间想歪弹开,退出由外向内缩放
相关文章推荐
- 自定义Dialog对话框并实现从底部弹出的动画效果
- 实现自定义对话框的动画效果:
- 21种ANDROID自定义DIALOG_动画弹出对话框效果组件
- Core Animation教学:使用Transitions制作带动画效果的向导对话框
- div弹出对话框(动画效果)
- 在Silverlight自定义验证效果(带动画)
- Android自定义Activity酷炫的动画跳转效果
- andriod 自定义view动画效果
- 自定义动画效果(Iris动画修改)
- 具有动画效果的对话框
- iOS学习之自定义弹出UIPickerView或UIDatePicker(动画效果)
- android 自定义对话框动画
- 在自定义对话框中显示Gallery的效果实现
- 对话框由小到大显示的动画效果
- Android对话框的自定义及透明效果
- 【转载】 iphone 半透明的自定义tabbar,带滑块动画效果
- div弹出对话框(动画效果)
- Flex4之自定义动画效果,使用自定义Parallel类来实现
- WP7进阶技巧 自定义Toast 提示动画效果
- 各种自定义动画效果