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条: ...
随机推荐
- iview render Datepicker 起止时间限制
{ title: '开始时间', key: 'planDateFrom', minWidth: 120, sortable: true, align: 'center', render: (h, pa ...
- Spring项目定时任务
最近某协会网站有个需求:显示当天访问量,很明显需要做俩步:一个是访问请求量的显示,一个需要每天00点恢复访问次数为0 所以需要做个定时任务:每天00点更新: 注解用法Spring配置: 1.在spri ...
- JAVA之字符串
求字符串长度: 使用.length()方法: 注意:字符串是使用字符串类里的方法,而数组是用数组类里的变量,因此数组是.length. String str="123456789" ...
- MySQL之执行流程
最近开始在学习mysql相关知识,自己根据学到的知识点,根据自己的理解整理分享出来,本篇文章会分析下一个sql语句在mysql中的执行流程,包括sql的查询在mysql内部会怎么流转,sql语句的更新 ...
- array数组(n,1)和(n,)互相转换
data.shape #(172,1) result = [arr[0] for arr in data] result.shape #(172,) (172,1)表示是一个(172,1)shape大 ...
- A Base Class pointer can point to a derived class object. Why is the vice-versa not true?
问题转载自:https://stackoverflow.com/questions/4937180/a-base-class-pointer-can-point-to-a-derived-class- ...
- java &与&& |与||的区别
一.与操作和或操作的区别 (1)在Java程序中,使用与操作,要求所有表达式的判断结果都是TRUE,才为真,若有一个为FALSE,那么最终判断结果则为FALSE (2)使用或操作,只要其中有一个表达式 ...
- C语言博客作业06--结构体&文件
1.本章学习总结 1.1思维导图 1.2.本章学习体会 这是这学期最后一次博客园作业,文件和结构体感觉比指针还难,一直搞不是很懂,大作业没有方向感,现在还在搞,大作业没有成品,只能先去借鉴舍友的优秀代 ...
- ctx中的body无法找到
学习koa的时候看到廖雪峰大大的文章 其中有一段写的总是报错找不到name 代码如下 router.get('/', async (ctx, next) => { ctx.response.bo ...
- Day 1 上午
唉,上午就碰到一个开不了机的电脑,白白浪费了半个小时,真的难受QwQ POINT1 枚举 枚举也称作穷举,指的是从问题所有可能的解的集合中一一枚举各元素. 用题目中给定的检验条件判定哪些是无用的,哪些 ...