android 如何设置alertdialog标题字体大小,Android-AlertDialog自定义标题样式、按钮颜色修改、多选列表宽颜色等修改...

本文介绍了如何使用原生AlertDialog在Android应用中创建自定义标题样式,包括居中文本、颜色调整以及多选列表框的样式修改。作者分享了自定义布局和颜色设置技巧,为提升UI一致性提供了实用方案。
摘要由CSDN通过智能技术生成

由于没有封装到之前的pop库,所以我就直接用AlertDialog原生的弹窗来搞了。然后坚定修改了下样式,快速完成了项目!后面再统一封装吧...

效果 - 紫色框就是做的修改...

a1fa0fe5eb7c

image

So.

1. 自定义标题样式

AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext);

// 自定义title,主要是为了居中

LayoutInflater layoutInflater = LayoutInflater.from(mContext);

View mTitleView = layoutInflater.inflate(R.layout.alertdialog_title, null);

((TextView)mTitleView.findViewById(R.id.txtPatient)).setText("申报状态选择");

alertBuilder.setCustomTitle(mTitleView);

alertdialog_title.xml

xmlns:app="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="wrap_content">

android:id="@+id/patient_top"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="@color/gray_all_bg"

app:layout_constraintTop_toTopOf="parent">

android:id="@+id/txtPatient"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginTop="12dp"

android:layout_marginBottom="12dp"

android:text="请选择项目地区"

android:textColor="@color/black_all_text"

android:textSize="18sp"

android:textStyle="bold"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent" />

2. 确定、取消颜色

alertDialogPlace = alertBuilder.create();

alertDialogPlace.show();

alertDialogPlace.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(Color.GRAY);

alertDialogPlace.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.BLACK);

3. 多选列表框颜色修改,界面style里面增加colorControlNormal和colorControlActivated

@color/white

@color/gray_f

@color/green_all_bg

设置给当前界面(记得是当前界面哟,而不是Application)

a1fa0fe5eb7c

image

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值