由下至上弹出并位于屏幕底部的提示框
2013-05-05 00:37
435 查看
androidencodinganimationdialog
[java]
view plaincopyprint?
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
AlertDialog dialog = new AlertDialog.Builder(TestAndroid1Activity.this)
.setTitle("title").setMessage("message").create();
Window window = dialog.getWindow();
window.setGravity(Gravity.BOTTOM); //此处可以设置dialog显示的位置
window.setWindowAnimations(R.style.mystyle);
//添加动画
dialog.show();
}
);
styles.xml
[java]
view plaincopyprint?
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="mystyle" parent="android:Animation">
<item name="@android:windowEnterAnimation">@anim/dialog_enter</item>
//进入时的动画
<item name="@android:windowExitAnimation">@anim/dialog_exit</item>
//退出时的动画
</style>
</resources>
位于 res/anim/dialog_enter.xml
[java]
view plaincopyprint?
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="100%p" %p指相对于父容器
android:duration="600"
/>
</set>
位于 res/anim/dialog_exit.xml
[java]
view plaincopyprint?
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:toYDelta="100%p"
android:duration="600"
//持续时间
/>
</set>
此处只是做了垂直位移的效果,自己还可以试试别的效果。
<alpha /> 透明度
<rotate /> 旋转
<scale /> 缩放
[java]
view plaincopyprint?
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
AlertDialog dialog = new AlertDialog.Builder(TestAndroid1Activity.this)
.setTitle("title").setMessage("message").create();
Window window = dialog.getWindow();
window.setGravity(Gravity.BOTTOM); //此处可以设置dialog显示的位置
window.setWindowAnimations(R.style.mystyle);
//添加动画
dialog.show();
}
);
button.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub AlertDialog dialog = new AlertDialog.Builder(TestAndroid1Activity.this) .setTitle("title").setMessage("message").create(); Window window = dialog.getWindow(); window.setGravity(Gravity.BOTTOM); //此处可以设置dialog显示的位置 window.setWindowAnimations(R.style.mystyle); //添加动画 dialog.show(); } });
styles.xml
[java]
view plaincopyprint?
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="mystyle" parent="android:Animation">
<item name="@android:windowEnterAnimation">@anim/dialog_enter</item>
//进入时的动画
<item name="@android:windowExitAnimation">@anim/dialog_exit</item>
//退出时的动画
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="mystyle" parent="android:Animation"> <item name="@android:windowEnterAnimation">@anim/dialog_enter</item> //进入时的动画 <item name="@android:windowExitAnimation">@anim/dialog_exit</item> //退出时的动画 </style> </resources>
位于 res/anim/dialog_enter.xml
[java]
view plaincopyprint?
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="100%p" %p指相对于父容器
android:duration="600"
/>
</set>
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="100%p" %p指相对于父容器 android:duration="600" /> </set>
位于 res/anim/dialog_exit.xml
[java]
view plaincopyprint?
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:toYDelta="100%p"
android:duration="600"
//持续时间
/>
</set>
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:toYDelta="100%p" android:duration="600" //持续时间 /> </set>
此处只是做了垂直位移的效果,自己还可以试试别的效果。
<alpha /> 透明度
<rotate /> 旋转
<scale /> 缩放
相关文章推荐
- android 实现由下至上弹出并位于屏幕底部的提示框
- Android 实现由下至上弹出并位于屏幕底部的提示框
- android 实现由下至上弹出并位于屏幕底部的提示框
- android 实现由下至上弹出并位于屏幕底部的提示框
- Android 实现由下至上弹出并位于屏幕底部的提示框
- android 实现由下至上弹出并位于屏幕底部的提示框
- android 实现由下至上弹出并位于屏幕底部的提示框【转】
- android 实现由下至上弹出并位于屏幕底部的提示框
- android 实现由下至上弹出并位于屏幕底部的提示框
- Android 实现由下至上弹出并位于屏幕底部的提示框
- android 实现由下至上弹出并位于屏幕底部的提示框
- android 实现由下至上弹出并位于屏幕底部的Dialog
- 如何制作一个总是位于屏幕底部的按钮
- Android实践-自定义dialog从屏幕底部弹出并且充满屏幕宽度
- Android实践-自定义dialog从屏幕底部弹出并且充满屏幕宽度
- 实现底部的弹出框(官方API实现Android的在屏幕中间)
- 从屏幕底部弹出PopupWindow
- 底部弹出alertDialog,宽度匹配屏幕宽
- 仿Iphone从屏幕底部弹出半透明的PopupWindow
- (转)Android Animation实战之屏幕底部弹出PopupWindow