当前位置: 首页 > news >正文

Android AlertDialog圆角背景不生效的问题

一行解决:

window?.setBackgroundDrawableResource(android.R.color.transparent)

原文件:

/*** Created by Xinghai.Zhao* 自定义选择弹框*/
@SuppressLint("InflateParams", "MissingInflatedId")
class CustomDialog(context: Context?) : AlertDialog(context){var mCallBack: ClickCallBack? = nullvar mTextViewTitle: TextView? = nullvar mTextViewContent: TextView? = nullvar mEditText:EditText? = nullvar mEditTextMax:TextView? = nullvar mEditLayout: View? = nullvar mTextViewYes: TextView? = nullvar mTextViewNo: TextView? = nullvar mLine: View? = nullvar isEdit:Boolean = falseconstructor(context: Context?, title: String?, content: String?, callBack: ClickCallBack, isEditType:Boolean) : this(context) {mCallBack = callBackisEdit = isEditTypemTextViewTitle?.text = title?:""mTextViewContent?.text = content?:""if (isEdit){mEditLayout?.visibility = View.VISIBLE}else{mEditLayout?.visibility = View.GONE}}init {val inflate = LayoutInflater.from(context).inflate(R.layout.dialog_custom, null)setView(inflate)window?.setBackgroundDrawableResource(android.R.color.transparent)//设置点击别的区域不关闭页面setCancelable(false)mTextViewTitle = inflate.findViewById(R.id.dialog_custom_title)mTextViewContent = inflate.findViewById(R.id.dialog_custom_content)mEditText = inflate.findViewById(R.id.dialog_custom_edit)mEditTextMax = inflate.findViewById(R.id.dialog_custom_edit_max)mEditLayout = inflate.findViewById(R.id.dialog_custom_edit_layout)mTextViewYes = inflate.findViewById(R.id.dialog_custom_yes)mTextViewYes?.setOnClickListener{mCallBack?.onYesClick(this)}mTextViewNo = inflate.findViewById(R.id.dialog_custom_no)mTextViewNo?.setOnClickListener{dismiss()}mLine = inflate.findViewById(R.id.dialog_custom_line)}interface ClickCallBack {fun onYesClick(dialog: CustomDialog)}
}

layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="@drawable/bg_set"android:orientation="vertical"><TextViewandroid:id="@+id/dialog_custom_title"android:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center"android:padding="20dp"android:textColor="@color/black"android:textSize="18sp"android:textStyle="bold" /><TextViewandroid:id="@+id/dialog_custom_content"android:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center"android:padding="30dp"android:textColor="@color/black"android:textSize="14sp" /><LinearLayoutandroid:id="@+id/dialog_custom_edit_layout"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:paddingBottom="20dp"android:visibility="gone"><EditTextandroid:id="@+id/dialog_custom_edit"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_marginStart="10dp"android:layout_weight="1"android:maxLength="10"android:maxLines="1"android:padding="10dp"android:textColor="@color/black"android:textSize="14sp" /><TextViewandroid:id="@+id/dialog_custom_edit_max"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginEnd="10dp"android:padding="10dp"android:textColor="@color/grey"android:textSize="12sp" /></LinearLayout><TextViewandroid:layout_width="match_parent"android:layout_height="1dp"android:background="@color/grey2" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><TextViewandroid:id="@+id/dialog_custom_no"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:gravity="center"android:padding="10dp"android:text="取消"android:textColor="@color/black"android:textSize="16sp" /><TextViewandroid:id="@+id/dialog_custom_line"android:layout_width="1dp"android:layout_height="match_parent"android:background="@color/grey2" /><TextViewandroid:id="@+id/dialog_custom_yes"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:gravity="center"android:padding="10dp"android:text="确定"android:textColor="@color/blue"android:textSize="16sp" /></LinearLayout>
</LinearLayout>

bg_set.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><corners android:radius="14dp" /> <!-- 圆角半径为10dp --><solid android:color="@color/white" /> <!-- 设置黑色背景并且70%不透明度 -->
</shape>

相关文章:

Android AlertDialog圆角背景不生效的问题

一行解决: window?.setBackgroundDrawableResource(android.R.color.transparent) 原文件: /*** Created by Xinghai.Zhao* 自定义选择弹框*/ SuppressLint("InflateParams", "MissingInflatedId") class CustomDialog(context: Context?) : AlertDia…...

探讨基于AI技术的相亲交友系统设计与实现

摘要 随着人工智能技术的发展&#xff0c;相亲交友领域也开始引入AI技术来改善用户体验&#xff0c;提高匹配成功率。本文探讨了如何利用AI技术设计并实现一个智能化的相亲交友系统&#xff0c;该系统能够根据用户的行为数据和个人偏好&#xff0c;自动推荐合适的潜在伴侣。通…...

(2024.9.20)Endnote插入的参考文献字号太大怎么办?

1、序言 常常写论文的人都知道&#xff0c;插入参考文献时&#xff0c;格式调整到让人头大。Endnote的使用大大方便了我们的同时&#xff0c;也意味着我们要学习软件的使用方法。最近重新安装了一下Endnote&#xff0c;插入的文献字体大小就像抽风了一样。在还没有写完文章之前…...

DataGrip在Windows和MacOS平台上的快捷键

0. 背景信息 No.说明1测试DataGrip版本号 : 2024.2.2 1. Windows下快捷键 2. MacOS下快捷键...

CSS---序号使用css设置,counter-reset、counter-increment、content配合实现备注文案的序号展示

直接上代码&#xff0c;全代码copy即可使用! <template><div class"reminder"><span class"Bold_12_body" style"line-height: 8vw">温馨提示&#xff1a;</span><br /><div class"rule-container"…...

Liquor 表达式引擎基本使用

引入依赖 <dependency><groupId>org.noear</groupId><artifactId>liquor-eval</artifactId><version>1.2.7</version> </dependency>liquor 表达式引擎&#xff08;ExpressionEvaluator&#xff09;支持 java 所有的类型、及…...

AI美女屠版小红书火了,被当真人推流,颜值博主慌了

最近&#xff0c;微信群里有一条炸裂的聊天记录&#xff0c;传得沸沸扬扬。 聊天记录原主声称&#xff0c;自己通过flux文生图模型跑出AI美女照片&#xff0c;发在小红书上不仅没有被平台标为AI&#xff0c;还成功获得流量扶持。 随后&#xff0c;原主就附上了自己养的1327个小…...

本地搭建我的世界服务器(JAVA)简单记录

网上参考教程挺多的&#xff0c;踩了不少坑&#xff0c;简单记录一下&#xff0c;我做的是一个私人服务器&#xff0c;就是和朋友3、4个人玩。 笨蛋 MC 开服教程 先放一个比较系统和完整的教程&#xff0c;萌新可用&#xff0c;这个教程很详细&#xff0c;我只是记录一下自己的…...

哪个快?用300万个图斑测试ArcGIS Pro的成对叠加与经典叠加

​​​ 点击下方全系列课程学习 点击学习—>ArcGIS全系列实战视频教程——9个单一课程组合系列直播回放 点击学习——>遥感影像综合处理4大遥感软件ArcGISENVIErdaseCognition 在使用ArcGIS Pro的过程中&#xff0c;很多朋友发现&#xff0c;Pro有个成对叠加工具集。很多…...

超详细!百分百安装成功pytorch,建议收藏

文章目录 一、Anaconda安装1.1下载anaconda1.2配置Anaconda环境1.3验证anaconda是否安装成功 二、查看电脑显卡三、更新显卡驱动3.1下载驱动3.2、查看显卡驱动版本 四、cuda安装4.1CUDA下载4.2CUDA环境配置4.3验证CUDA是否安装成功 五、安装pytorch4.1下载pytorch5.2验证pytorc…...

web基础—dvwa靶场(四)​File Inclusion

File Inclusion(文件包含) 有些 web 应用程序允许用户指定直接文件流的输入&#xff0c;或允许用户将文件上载到服务器。稍后 web 应用程序访问 web 应用程序上下文中用户提供的输入。通过这样种操作&#xff0c;web 应用程序允许恶意文件执行。 如果选择要包含的文件是目标计…...

【Python】练习:控制语句(二)第1关

第1关&#xff1a;分支结构基础实训 第一题第二题第三题第四题&#xff08;※&#xff09;第五题&#xff08;※&#xff09;第六题第七题 第一题 #第一题 for temp in [-280, -100, 0, 20, 120, 200]:#请在下面编写代码# ********** Begin ********** #if temp>-273.15:F9/…...

Vue3 : Pinia的性质与作用

目录 一.性质 二.作用 三.Pinia 的核心概念 四.使用 1.count.ts 2.count.vue Vue 3 中 Pinia 是一个专为 Vue 3 设计的状态管理库&#xff0c;它旨在提供一种简单、直观的方式来管理应用的状态。 一.性质 1.集成性&#xff1a;Pinia 是 Vue 3 官方推荐的状态管理库&…...

对接金蝶云星空调用即时库存信息查询API

文章目录 前言准备工作获取第三方授权权限与授权配置信息集成金蝶云SDK调用实现备注前言 对于有自己商品信息管理后台并且使用金蝶ERP系统管理物料的商家来说,将金蝶上物料的库存信息同步到管理后台就可以不用去金蝶上确认库存了,可以大大简化管理后台的库存变更工作,这篇文…...

pretrain Llama3

导入模块&#xff1a;导入了一些必要的模块&#xff0c;包括数学计算、时间处理、文件操作、深度学习框架&#xff08;如torch&#xff09;、以及自定义的LLama Transformer模型相关内容。 I/O配置&#xff1a;定义了模型输出路径、评估与日志记录的间隔步数、批次大小、最大序…...

[附源码]SpringBoot+VUE+Java实现人脸识别系统

今天带来一款优秀的项目&#xff1a;java人脸识别系统源码 。 系统采用的流行的前后端分离结构&#xff0c;内含功能包括 “人脸数数据录入”&#xff0c;“人脸管理”&#xff0c;“摄像头识别” 如果您有任何问题&#xff0c;也请联系小编&#xff0c;小编是经验丰富的程序员…...

数据库_解决SQL Server数据库log日志过大,清理日志文件方法

SQL Server数据库日志文件过大的原因主要有几个方面&#xff1a; 事务日志记录了所有对数据库进行修改的操作&#xff0c;如插入、更新和删除&#xff0c;这些操作会不断增加日志文件的大小。 长时间运行且未正确结束的事务会持续占用事务日志中的空间&#xff0c;导致日志文…...

引领长期投资新篇章:价值增长与财务安全的双重保障

随着全球金融市场的不断演变&#xff0c;长期投资策略因其稳健性和对价值增长的显著推动作用而日益受到投资者的重视。在这一背景下&#xff0c;Zeal Digital Shares&#xff08;ZDS&#xff09;项目以其创新的数字股票产品&#xff0c;为全球投资者提供了一个全新的长期投资平…...

灾备技术演进之路 | 虚拟化无代理备份只能挂载验证和容灾吗?只能无代理恢复吗?且看科力锐升级方案

灾备技术演进之路系列 虚拟化备份技术演进 摆脱束缚&#xff0c;加速前行 无代理备份仅能挂载/恢复验证吗&#xff1f; ——科力锐极简验证演练无代理备份来了 无代理备份无法应对平台级故障吗&#xff1f; ——科力锐应急接管无代理备份来了 无代理备份仅能同平台挂载吗&a…...

PowerShell install 一键部署Oracle23ai

Oracle23ai前言 Oracle Database 23ai Free 让您可以充分体验 Oracle Database 的能力,世界各地的企业都依赖它来处理关键任务工作负载。 Oracle Database Free 的资源限制为 2 个 CPU(前台进程)、2 GB 的 RAM 和 12 GB 的磁盘用户数据。该软件包不仅易于使用,还可轻松下载…...

Docker 离线安装指南

参考文章 1、确认操作系统类型及内核版本 Docker依赖于Linux内核的一些特性&#xff0c;不同版本的Docker对内核版本有不同要求。例如&#xff0c;Docker 17.06及之后的版本通常需要Linux内核3.10及以上版本&#xff0c;Docker17.09及更高版本对应Linux内核4.9.x及更高版本。…...

【Linux】C语言执行shell指令

在C语言中执行Shell指令 在C语言中&#xff0c;有几种方法可以执行Shell指令&#xff1a; 1. 使用system()函数 这是最简单的方法&#xff0c;包含在stdlib.h头文件中&#xff1a; #include <stdlib.h>int main() {system("ls -l"); // 执行ls -l命令retu…...

django filter 统计数量 按属性去重

在Django中&#xff0c;如果你想要根据某个属性对查询集进行去重并统计数量&#xff0c;你可以使用values()方法配合annotate()方法来实现。这里有两种常见的方法来完成这个需求&#xff1a; 方法1&#xff1a;使用annotate()和Count 假设你有一个模型Item&#xff0c;并且你想…...

el-switch文字内置

el-switch文字内置 效果 vue <div style"color:#ffffff;font-size:14px;float:left;margin-bottom:5px;margin-right:5px;">自动加载</div> <el-switch v-model"value" active-color"#3E99FB" inactive-color"#DCDFE6"…...

用docker来安装部署freeswitch记录

今天刚才测试一个callcenter的项目&#xff0c;所以尝试安装freeswitch 1、使用轩辕镜像 - 中国开发者首选的专业 Docker 镜像加速服务平台 编辑下面/etc/docker/daemon.json文件为 {"registry-mirrors": ["https://docker.xuanyuan.me"] }同时可以进入轩…...

Spring Cloud Gateway 中自定义验证码接口返回 404 的排查与解决

Spring Cloud Gateway 中自定义验证码接口返回 404 的排查与解决 问题背景 在一个基于 Spring Cloud Gateway WebFlux 构建的微服务项目中&#xff0c;新增了一个本地验证码接口 /code&#xff0c;使用函数式路由&#xff08;RouterFunction&#xff09;和 Hutool 的 Circle…...

【数据分析】R版IntelliGenes用于生物标志物发现的可解释机器学习

禁止商业或二改转载&#xff0c;仅供自学使用&#xff0c;侵权必究&#xff0c;如需截取部分内容请后台联系作者! 文章目录 介绍流程步骤1. 输入数据2. 特征选择3. 模型训练4. I-Genes 评分计算5. 输出结果 IntelliGenesR 安装包1. 特征选择2. 模型训练和评估3. I-Genes 评分计…...

NXP S32K146 T-Box 携手 SD NAND(贴片式TF卡):驱动汽车智能革新的黄金组合

在汽车智能化的汹涌浪潮中&#xff0c;车辆不再仅仅是传统的交通工具&#xff0c;而是逐步演变为高度智能的移动终端。这一转变的核心支撑&#xff0c;来自于车内关键技术的深度融合与协同创新。车载远程信息处理盒&#xff08;T-Box&#xff09;方案&#xff1a;NXP S32K146 与…...

云原生安全实战:API网关Kong的鉴权与限流详解

&#x1f525;「炎码工坊」技术弹药已装填&#xff01; 点击关注 → 解锁工业级干货【工具实测|项目避坑|源码燃烧指南】 一、基础概念 1. API网关&#xff08;API Gateway&#xff09; API网关是微服务架构中的核心组件&#xff0c;负责统一管理所有API的流量入口。它像一座…...

提升移动端网页调试效率:WebDebugX 与常见工具组合实践

在日常移动端开发中&#xff0c;网页调试始终是一个高频但又极具挑战的环节。尤其在面对 iOS 与 Android 的混合技术栈、各种设备差异化行为时&#xff0c;开发者迫切需要一套高效、可靠且跨平台的调试方案。过去&#xff0c;我们或多或少使用过 Chrome DevTools、Remote Debug…...