dialog学习

 

 

 

11.dialog底部弹出动画:

====

11.dialog底部弹出动画:

 

点击Button调用代码

 private void show() {
        Dialog dialog = new Dialog(this);
        //去掉标题线 dialog.requestWindowFeature(android.view.Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog); //背景透明 dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent); dialog.show(); Window window = dialog.getWindow(); WindowManager.LayoutParams lp = window.getAttributes(); lp.gravity = Gravity.CENTER; // 居中位置 lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; window.setAttributes(lp); window.setWindowAnimations(R.style.mystyle); //添加动画 } 

Dialog的自定义布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical"> <LinearLayout android:layout_width="300dp" android:layout_height="wrap_content" android:background="@drawable/dialog" android:gravity="center" android:orientation="vertical" android:padding="10dp"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="用户名" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="密码" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="确定" /> </LinearLayout> </LinearLayout> 

Dialog的自定义布局Share样式,drawable里面新建

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <!--圆角--> <corners android:radius="30dp" /> <!--填充色--> <solid android:color="#ffffff" /> </shape> 

弹出动画样式,在styles里面添加

 <!--弹窗动画-->
    <style name="mystyle" parent="android:Animation"> <!--//进入时的动画--> <item name="@android:windowEnterAnimation">@anim/dialog_enter</item> <!--//退出时的动画--> <item name="@android:windowExitAnimation">@anim/dialog_exit</item> </style> 

弹出动画,新建anim文件目录,一个进入 一个退出的,

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:duration="500" android:fromYDelta="100%" android:toYDelta="0" /> </set> 

退出的

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:duration="500" android:fromYDelta="0" android:toYDelta="100%" /> </set> 

参考大神的文章 http://www.jianshu.com/p/9e3cac6aca17
主要是自己备份下。。。顺便能帮到人更好哈哈

链接:https://www.jianshu.com/p/ccf6a3c23c72
 

 

转载于:https://www.cnblogs.com/awkflf11/p/9788887.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值