创建一个从底部显示的对话框

if (dialog == null) {
dialog = new Dialog(context, R.style.theme_from_bottom);
View view = View.inflate(context, R.layout.udialog, null);
ImageView closeView = view.findViewById(R.id.user_contract_close_view);
Button button = view.findViewById(R.id.user_contract_im_view);
dialog.setContentView(view);
dialog.setCancelable(false); //设置自适应的方法:
WindowManager.LayoutParams dialogParams = contactDialog.getWindow().getAttributes();
dialogParams.width = WindowManager.LayoutParams.MATCH_PARENT;
dialogParams.height = WindowManager.LayoutParams.WRAP_CONTENT; //设置底部显示
dialogParams.gravity = Gravity.BOTTOM;
contactDialog.getWindow().setAttributes(dialogParams); //设置窗口大小的方法:
int with = (int) (context.getResources().getDisplayMetrics().widthPixels * 0.6)
int height = (int) (context.getResources().getDisplayMetrics().heightPixels * 0.4); //对话框重置属性
contactDialog.getWindow().setAttributes(dialogParams);
}

xml 文件

 <style name="theme_from_bottom" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@style/dialog_bottom</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style> <style name="dialog_bottom" parent="@android:style/Animation.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowEnterAnimation">@anim/dialog_bottom_in</item>
<item name="android:windowExitAnimation">@anim/dialog_bottom_out</item>
</style>  动画
dialog_bottom_in
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="300"
android:fromYDelta="100%p"
android:toYDelta="0"
/>
<alpha
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="300" />
</set>
dialog_bottom_out
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="300"
android:fromYDelta="0"
android:toYDelta="100%p" />
<alpha
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="300" />
</set>

dialog自适应大小、固定大小、底部显示的更多相关文章

  1. 【转】javascript弹出固定大小的窗口页面

    来源:http://weicfprince.blog.163.com/blog/static/8441066920081010113231969/ 现在我们想弹出一个WEB窗体,让其处于屏幕的中间位置 ...

  2. fusioncharts的3D饼图固定大小和角度

    3D饼图的pieRadius和startingAngle属性 pieRadius:饼图的半径 startingAngle:饼图的角度(旋转) 在固定大小的div里面,饼图上如果显示label或者val ...

  3. JavaScript自适应调整文字大小

    JavaScript自适应调整文字大小 今天有个任务,发现页面上的数字由于太长而与其他数字重叠了.这个数字还不能像文字那样只显示一部分,必须全部显示.想了一些办法都不行,最后把超过1000变成1K,大 ...

  4. 使用SplFixedArray创建固定大小的数组

    PHP在定义数组的时候不用像C或Java一样定义数组大小,PHP数组可以根据我们的需要增长或收缩.但这种灵活性在内存使用方面带来很大的不便. 而PHP中可以使用SplFixedArray创建固定大小的 ...

  5. mui在tab选项卡中echarts图表不能动态随页面变化大小 只能固定大小

    在mui tab选项卡中一直都不能让echarts动态变化大小 只能固定大小来展示图表,网上说的window.onresize = mycharts.resize;方法根本就没有效果,后面在https ...

  6. textarea 在浏览器中固定大小和禁止拖动

    HTML 标签 textarea 在大部分浏览器中只要指定行(rows)和列(cols)属性,就可以规定 textarea 的尺寸,大小就不会改变,不过更好的办法是使用 CSS 的 height 和 ...

  7. 点击弹出固定大小的新窗口(js实现)

    <SCRIPT LANGUAGE="javascript"> <!-- window.open ('page.html') --> </SCRIPT& ...

  8. textarea 怎么固定大小,不让调整

    1:彻底禁用拖动(推荐) resize: none; 2:只是固定大小,右下角的拖动图标仍在 width: 200px; height: 100px; max-width: 200px; max-he ...

  9. Mina、Netty、Twisted一起学(三):TCP消息固定大小的前缀(Header)

    在上一篇博文中,有介绍到用换行符分割消息的方法.但是这种方法有个小问题,如果消息中本身就包含换行符,那将会将这条消息分割成两条,结果就不对了. 本文介绍另外一种消息分割方式,即上一篇博文中讲的第2条: ...

随机推荐

  1. Word报告自动生成(例如 导出数据库结构)

    将很早之前写的一个小组件重新整理优化一下,做成一个通用的功能.适用于导出数据库的结构(表.字段等)到Word或将体检数据自动生成Word版的体检报告等.代码:Github 一.主要需要完成功能: 1. ...

  2. Python----多项式回归

    多项式线性回归 1.多项式线性方程: 与多元线性回归相比,它只有一个自变量,但有不同次方数. 2.举例: import numpy as np import matplotlib.pyplot as ...

  3. Arguments Optional 计算两个参数之和的 function

    创建一个计算两个参数之和的 function.如果只有一个参数,则返回一个 function,该 function 请求一个参数然后返回求和的结果. 例如,add(2, 3) 应该返回 5,而 add ...

  4. flutter-开发总结

    ### 上拉加载下拉刷新 ``` import 'dart:async'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import ...

  5. 在Asp.Net Core中集成ABP Dapper

    在实际的项目中,除了集成ABP框架的EntityFrameworkCore以外,在有些特定的场景下不可避免地会使用一些SQL查询语句,一方面是由于现在的EntityFrameworkCore2.X有些 ...

  6. CnPack IDE 专家包(CnWizards)显示代引用单元列表

    CnWizards_1.1.3.896

  7. request+response+jsp+el+jstl

    response: 1.设置响应行的状态码: response.setStatus(int sc); 2.设置response缓冲区的编码:response.setCharacterEncoding( ...

  8. 线性回归中常见的一些统计学术语(RSE RSS TSS ESS MSE RMSE R2 Pearson's r)

    TSS: Total Sum of Squares(总离差平方和) --- 因变量的方差 RSS: Residual Sum of Squares (残差平方和) ---  由误差导致的真实值和估计值 ...

  9. 如何规避“Flash中国特供版”

    如何规避“Flash中国特供版” 来源  http://blog.sina.com.cn/s/blog_4e1bc3e90102xn0k.html 浏览国内网站,尤其是一些很重要或者很常用,但是很落后 ...

  10. CSS上下左右居中的几种方法

    1.absolute,margin: auto .container { position: relative; } .content { position: absolute; margin: au ...