对话框改变颜色 宽度沾满屏幕 Dialog
首先在style.xml中定义一个对话框样式,这里可以修改颜色:
//对话框沾满整个屏幕的宽度 <style name="DialogShareTheme" parent="Theme.AppCompat.Dialog"> <item name="android:background">@color/white</item> <item name="android:windowBackground">@color/transparent</item> </style>
接着编写对话框的布局文件,这里就只写了一个按钮:
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Test" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> </android.support.constraint.ConstraintLayout>
java代码中:
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ProductionInformationActivity.this, R.style.DialogShareTheme); //加入样式 final View dialogView = LayoutInflater.from(ProductionInformationActivity.this).inflate(R.layout.dialog_share,null); //加入布局 dialogBuilder.setView(dialogView); Dialog dialog = dialogBuilder.create(); dialog.getWindow().setGravity(Gravity.BOTTOM); dialog.show(); WindowManager.LayoutParams p = dialog.getWindow().getAttributes(); p.width = MyApp.getScreenWidth(this); //设置dialog的宽度为当前手机屏幕的宽度 dialog.getWindow().setAttributes(p);
效果:
对话框改变颜色 宽度沾满屏幕 Dialog的更多相关文章
- VC 对话框背景颜色、控件颜色(三种方法)
系统环境:Windows 7软件环境:Visual C++ 2008 SP1本次目的:为对话框设置背景颜色.控件颜色 既然MFC对话框不好开发,那么现在我们来开始美化我们的对话框.为对话框设置背景颜色 ...
- VC 对话框背景颜色、控件颜色
系统环境:Windows 7软件环境:Visual C++ 2008 SP1本次目的:为对话框设置背景颜色.控件颜色 既然MFC对话框不好开发,那么现在我们来开始美化我们的对话框.为对话框设置背景颜色 ...
- android中自定义view---实现竖直方向的文字功能,文字方向朝上,同时提供接口,判断当前touch的是哪个字符,并改变颜色
android自定义view,实现竖直方向的文字功能,文字方向朝上,同时提供接口,判断当前touch的是哪个字符,并改变颜色. 由于时间比较仓促,因此没有对代码进行过多的优化,功能远远不如androi ...
- 让UITableViewCell的分隔线宽度等于屏幕的宽度
3种方法: 1.自定义cell: 1).取消系统的分隔线 2).添加一个高度为1,宽度为屏幕宽度的UIView作为cell的子视图,通过设置frame或者约束使这个UIView始终在cell的底部 3 ...
- VS2010/MFC对话框:颜色对话框
颜色对话框 在上一节中为大家讲解了字体对话框的使用方法,熟悉了字体对话框,本节继续讲另一种通用对话框--颜色对话框. 颜色对话框大家肯定也不陌生,我们可以打开它选择需要的颜色,简单说,它的作用就是用来 ...
- QDialog:输入对话框、颜色对话框、字体对话框、文件对话框
# _*_ coding:utf-8 _*_ import sys from PyQt4 import QtCore,QtGui class Example(QtGui.QWidget): def _ ...
- VS2010/MFC编程入门之十九(对话框:颜色对话框)
鸡啄米在上一节中为大家讲解了字体对话框的使用方法,熟悉了字体对话框,本节继续讲另一种通用对话框--颜色对话框. 颜色对话框大家肯定也不陌生,我们可以打开它选择需要的颜色,简单说,它的作用就是用来选择颜 ...
- 常量,字段,构造方法 调试 ms 源代码 一个C#二维码图片识别的Demo 近期ASP.NET问题汇总及对应的解决办法 c# chart控件柱状图,改变柱子宽度 使用C#创建Windows服务 C#服务端判断客户端socket是否已断开的方法 线程 线程池 Task .NET 单元测试的利剑——模拟框架Moq
常量,字段,构造方法 常量 1.什么是常量 常量是值从不变化的符号,在编译之前值就必须确定.编译后,常量值会保存到程序集元数据中.所以,常量必须是编译器识别的基元类型的常量,如:Boolean ...
- jquery动态改变div宽度和高度
效果体验:http://keleyi.com/keleyi/phtml/jquery/23.htm 完整代码: <!DOCTYPE html PUBLIC "-//W3C//DTD X ...
随机推荐
- Linux上安装MangoDB
版本 MongDB4.0.3 安装 tar -zxvf mongodb-linux-x86_64-rhel62-4.0.3.tgz默认的数据目录在/data/db,也可以指定目录启动命令./bin/m ...
- 【SpringBoot】SpringBoot拦截器实战和 Servlet3.0自定义Filter、Listener
=================6.SpringBoot拦截器实战和 Servlet3.0自定义Filter.Listener ============ 1.深入SpringBoot2.x过滤器Fi ...
- SSM框架的配置
主要是这三个配置文件 web.xml(用来加载和初始化下面的配置文件) applicationcontet.xml(就是Spring的配置文件,一般包括声明式失误等等AOP) Sprimgmvc,xm ...
- JS 点击复制
一.原理分析 浏览器提供了 copy 命令 ,可以复制选中的内容 document.execCommand("copy") 如果是输入框,可以通过 select() 方法,选中输入 ...
- 模拟器运行android镜像
编译完成后需要运行一下,看看效果,操作中出现很多问题 先说明android4.0的,然后说明一下android2.3.4的,两者是一样的 一.android4.0.1 可以参看如下链接: ht ...
- repos配置
- C#编程经验-enum and struct
enum,store fixed values,use array replace,not use this data-structurestruct,store several variables, ...
- 2017-07-06 eclipse在线安装SVN1.9插件
1,百度搜索subeclipse,点击第一个: 2,官网说,文档已移动到github wiki上: 3,打开github wiki,复制最新发布版本地址: 4,在eclipse里面,打开help-&g ...
- MYSQL存储过程实现用户登录
MYSQL存储过程实现用户登录 CREATE DEFINER=`root`@`%` PROCEDURE `uc_session_login`( ), ) ) LANGUAGE SQL NOT DETE ...
- 使用 tag 文件定义自定义标签
----------------------------------------------------------------------- 在jsp文件中,可以引用tag和tld文件. 1.对于t ...