如何使从下一个对话框,幻灯片屏幕的android的中间 [英] How to make a dialog slide from bottom to middle of screen in android

查看:122
本文介绍了如何使从下一个对话框,幻灯片屏幕的android的中间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想告诉我的动画活动的对话框。我的对话将从活动的底部滑动到活动的中间。

/ *的修改的* /

我很抱歉,我的问题是不清楚。我的意思是我的对话框将幻灯片从底部到中间,但对话框的底部放置在活动的底部,这样下面的图片输入图像的描述在这里

解决方案

有关这一点,你需要2个动画,并把这个在RES /阿尼姆文件夹

  1. slide_up_dialog.xml

 < XML版本=1.0编码=UTF-8&GT?;
<翻译的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:fromYDelta =50%P机器人:toYDelta =0%P
    机器人:时间=@安卓整数/ config_longAnimTime/>
 

2.slide_out_down.xml

 < XML版本=1.0编码=UTF-8&GT?;
<翻译的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:时间=@安卓整数/ config_longAnimTime
    机器人:fromYDelta =0%P
    机器人:toYDelta =100%P/>
 

现在你必须创建在style.xml自定义样式

 <样式名称=DialogAnimation>
        <项目名称=机器人:windowEnterAnimation> @动画/ slide_up_dialog< /项目>
        <项目名称=机器人:windowExitAnimation> @动画/ slide_out_down< /项目>
< /风格>
 

其次是扩大在同一style.xml了Android Theme.Dialog主题,并给予参考我们创建自定义样式。

 <! - 动画的对话框 - >
    <样式名称=DialogSlideAnim父=@安卓风格/ Theme.Dialog>
        <项目名称=机器人:windowAnimationStyle> @风格/ DialogAnimation< /项目>
    < /风格>
 

当你创建对话框类似这样的

和最后调用这种风格。

 对话框=新的对话框(这一点,R.style.DialogSlideAnim);
 

叶氏....现在对话已经准备好滑...... !!

I want to show a dialog on my activity with animation. My dialog will slide from bottom of activity to middle of activity.

/*Edit*/

I'm sorry for my question is unclear. I mean that my dialog will be slide from bottom to middle but the bottom side of dialog is placed on bottom side of activity , like this following picture

解决方案

For this you need 2 animation and put this in res/anim folder

  1. slide_up_dialog.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="50%p" android:toYDelta="0%p"
    android:duration="@android:integer/config_longAnimTime"/>

2.slide_out_down.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@android:integer/config_longAnimTime"
    android:fromYDelta="0%p"
    android:toYDelta="100%p" />

Now you have to create a custom style in style.xml

<style name="DialogAnimation">
        <item name="android:windowEnterAnimation">@anim/slide_up_dialog</item>
        <item name="android:windowExitAnimation">@anim/slide_out_down</item>
</style>

Next is to extend the android Theme.Dialog theme in the same style.xml and give the reference to the custom style we created.

<!-- Animation for dialog box -->
    <style name="DialogSlideAnim" parent="@android:style/Theme.Dialog">
        <item name="android:windowAnimationStyle">@style/DialogAnimation</item>
    </style>

And finally call this style when you create the dialog like this.

dialog = new Dialog(this, R.style.DialogSlideAnim);

yeap....Now the Dialog is ready to slide.....!!

这篇关于如何使从下一个对话框,幻灯片屏幕的android的中间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆