dialog自适应大小、固定大小、底部显示
创建一个从底部显示的对话框
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自适应大小、固定大小、底部显示的更多相关文章
- 【转】javascript弹出固定大小的窗口页面
来源:http://weicfprince.blog.163.com/blog/static/8441066920081010113231969/ 现在我们想弹出一个WEB窗体,让其处于屏幕的中间位置 ...
- fusioncharts的3D饼图固定大小和角度
3D饼图的pieRadius和startingAngle属性 pieRadius:饼图的半径 startingAngle:饼图的角度(旋转) 在固定大小的div里面,饼图上如果显示label或者val ...
- JavaScript自适应调整文字大小
JavaScript自适应调整文字大小 今天有个任务,发现页面上的数字由于太长而与其他数字重叠了.这个数字还不能像文字那样只显示一部分,必须全部显示.想了一些办法都不行,最后把超过1000变成1K,大 ...
- 使用SplFixedArray创建固定大小的数组
PHP在定义数组的时候不用像C或Java一样定义数组大小,PHP数组可以根据我们的需要增长或收缩.但这种灵活性在内存使用方面带来很大的不便. 而PHP中可以使用SplFixedArray创建固定大小的 ...
- mui在tab选项卡中echarts图表不能动态随页面变化大小 只能固定大小
在mui tab选项卡中一直都不能让echarts动态变化大小 只能固定大小来展示图表,网上说的window.onresize = mycharts.resize;方法根本就没有效果,后面在https ...
- textarea 在浏览器中固定大小和禁止拖动
HTML 标签 textarea 在大部分浏览器中只要指定行(rows)和列(cols)属性,就可以规定 textarea 的尺寸,大小就不会改变,不过更好的办法是使用 CSS 的 height 和 ...
- 点击弹出固定大小的新窗口(js实现)
<SCRIPT LANGUAGE="javascript"> <!-- window.open ('page.html') --> </SCRIPT& ...
- textarea 怎么固定大小,不让调整
1:彻底禁用拖动(推荐) resize: none; 2:只是固定大小,右下角的拖动图标仍在 width: 200px; height: 100px; max-width: 200px; max-he ...
- Mina、Netty、Twisted一起学(三):TCP消息固定大小的前缀(Header)
在上一篇博文中,有介绍到用换行符分割消息的方法.但是这种方法有个小问题,如果消息中本身就包含换行符,那将会将这条消息分割成两条,结果就不对了. 本文介绍另外一种消息分割方式,即上一篇博文中讲的第2条: ...
随机推荐
- cat
cat命令能够显示或拼接文件内容,它本身表示conCATenate(拼接) 一般语法 打印单个文件的内容 [root@VM_0_15_centos ~]# cat output.session 打印多 ...
- Python两个栈实现一个队列
牛客网原题: 用两个栈来实现一个队列,完成队列的Push和Pop操作. 队列中的元素为int类型. 实现这个算法的方式有很多种,这里就写一种比较简单易懂的:虽然可能算法和效率上不太出色,当大多数人 ...
- 解决SecureCRT无法连接虚拟机的问题
- 微信支付之02------整个微信支付功能----------Java实现
先来看下微信支付官方文档: 1.在官方文档上有很多种支付方式,由于目前我只做过JSAPI和微信扫码支付二种,其他的就不说了. >>>>>第一种微信扫码支付>> ...
- 深入理解SpringIOC容器
转载来源:[https://www.cnblogs.com/fingerboy/p/5425813.html] 前言: 在逛博客园的时候突然发现一篇关于事务的好文章,说起spring事物就离不开AOP ...
- 项目中写到看到的一些LINQ和Lambda语句
1,求和 var datas = SellOutActualData.Where(b => b.BrandCode == brandExportParam.BrandInfo.BrandCode ...
- 上传图片,通过node服务器存储在指定目录
最近做毕设,需要上传图片,因为在本地服务器运行,所以想着前端上传后,通过node服务器接收图片,存储在指定的目录下. 一.前端实现 1.前端的页面和上传图片是利用element-ui组件实现的,&qu ...
- 【地图功能开发系列:二】根据地址名称通过百度地图API查询出坐标
根据地址名称通过百度地图API查询出坐标 百度地图ApiUrl string url = "http://api.map.baidu.com/geocoder?address={0}& ...
- ubuntu mirror
# apt-mirror configuration file ## The default configuration options (uncomment and change to overri ...
- opencv debug版本在linux下编译,并写了一个DEMO
用如下方法编译opencv: git clone "https://github.com/opencv/opencv.git" mkdir opencv_debug cd open ...