Android 修改AlertDialog原生setPositiveButton的字体颜色背景颜色大小边距位置

article/2025/9/26 11:50:06

 看效果图:

 

  public void lanyaClick(View v) {//点击确定之后转向登陆框LayoutInflater factory = LayoutInflater.from(Beforestart.this);//得到自定义对话框final View DialogView = factory.inflate(R.layout.item_alert_dialog, null);//创建对话框android.app.AlertDialog dlg = new AlertDialog.Builder(Beforestart.this).setTitle("").setView(DialogView).setPositiveButton("登录", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int whichButton) {Button Button1 = (Button) findViewById(R.id.blechongdian);//添加按钮点击事件的监听器Button1.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {binder.setData("Loginpassword", //实现界面跳转Intent intent = new Intent();intent.setClass(Beforestart.this, BluetoothCharging.class);startActivity(intent);}});}}).create();dlg.getWindow().setBackgroundDrawableResource(R.drawable.yuanjiao5); //设置对话框的样式dlg.show();Button button = dlg.getButton(AlertDialog.BUTTON_POSITIVE);LinearLayout.LayoutParams cancelBtnPara = (LinearLayout.LayoutParams) button.getLayoutParams();//设置按钮的大小cancelBtnPara.height = LinearLayout.LayoutParams.WRAP_CONTENT;cancelBtnPara.width = LinearLayout.LayoutParams.MATCH_PARENT;//设置文字居中cancelBtnPara.gravity = Gravity.CENTER;//设置按钮左上右下的距离cancelBtnPara.setMargins(100, 50, 100, 30);button.setLayoutParams(cancelBtnPara);button.setBackground(ContextCompat.getDrawable(this, R.drawable.bg_yuanjiao));button.setTextColor(ContextCompat.getColor(this, R.color.white));button.setTextSize(16);}

 主要的代码是show下面的:

 


http://chatgpt.dhexx.cn/article/cAByMQvh.shtml

相关文章

setPositiveButton和setNegativeButton的区别

setPositiveButton和setNegativeButton的区别和setNeutralButton的区别 三者都是AlertDialog弹出框的按钮,都是封装好的button,只是显示的位置不同,项目中可根据情况选择使用,setNegativeButton一般用于确认,setNegat…

GPS(rinex格式)数据解析详细解读

RINEX格式现如今已成为GPS测量应用中的标准数据格式,目前应用最为广泛、最普遍的是RINEX格式的第2个版本,该版本能够用于包括静态和动态GPS测量在内的不同观测模式数据。在该版本中定义了6种不同类型的数据文件,分别用于存放不同类型的数据&a…

2020/10/23 GPS的数据格式学习

GPS的数据格式学习 一、在使用GPS的通过串口向电脑发送数据的时候,要注意GPS数据线的连接; 1.1 VCC接VCC;(VCC表示接电源正极) 1.2 GND接GND;(GND表示接地或接电源负极) 1.3 TX接RX…

GPS数据包格式+数据解析

GPS数据包格式数据解析 一、全球时区的划分: 每个时区跨15经度。以0经线为界向东向西各划出7.5经度,作为0时区。即0时区的经度范围是7.5W——7.5E。从7.5E与7.5W分别向东、向西每15经度划分为一个时区,直到东11区和西11区。东11区最东部的经度…

GPS研究---GPS 数据格式

GPS 数据处理时所采用的观测数据是来自观测的 GPS 接收机。由于接收机的型号很多,厂商设计的数据格式各不相同,国际上为了能统一使用不同接收机的数据, 设计了一种与接收机无关的 RINEX(The Receiver Independent Exchange Format)格式&#…

GPS数据格式的分析

文章目录 前言一、数据格式解析1、GPGGA2、GPRMC3、GPCHC4、Kitti数据集oxts数据 二、驱动1、功能包1.1 解析GPGGA1.2 华测GPCHC 2、ROS相关消息类型2.1 sensor_msgs::NavSatFix2.2 gps_common::GPSFix2.3 sensor_msgs::Imu 3、驱动思路 三、时间1、UTC时间2、时间戳 前言 GPS…

GPS GLONASS数据文件类型解析

GPS & GLONASS数据文件类型解析 一、GPS数据格式 RINEX格式现如今已成为GPS测量应用中的标准数据格式,目前应用最为广泛、最普遍的是RINEX格式的第2个版本,该版本能够用于包括静态和动态GPS测量在内的不同观测模式数据。在该版本中定义了6种不同类…

GPS的数据格式介绍

GPRMC&#xff08;建议使用最小GPS数据格式&#xff09; $GPRMC,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>,<9>,<10>,<11><CR><LF> 1) 标准定位时间&#xff08;UTC time&#xff09;格式&#xff1a…

Android ExpandableListView

ExpandableListView可以显示一个视图垂直滚动显示两级列表中的条目&#xff0c;这不同于列表视图&#xff08;ListView&#xff09;。ExpandableListView允许有两个层次&#xff1a;一级列表中有二级列表。 比如在手机设置中&#xff0c;对于分类&#xff0c;有很好的效果。手机…

ExpandableListView用法

先上个效果图&#xff1a; 1&#xff0c;我用的fragment import java.util.ArrayList; import java.util.Collections; import java.util.List; import com.dami.student.ui.chatui.adapter.ContactsExpandableListAdapter; import com.dami.student.R; import android.conten…

android expandablelistview简单应用,android ExpandableListView简单例子

android中常常要用到ListView&#xff0c;有时也要用到ExpandableListView&#xff0c;如在手机设置中&#xff0c;对于分类有很好的效果&#xff0c;会用ListView的人一定会用ExpandableListView&#xff0c;因为 ExpandableListView extends ListView的&#xff0c;下面来看个…

android expandablelistview横向,完美实现ExpandableListView二级分栏效果

本文实例为大家分享了ExpandableListView二级分栏效果的具体代码&#xff0c;供大家参考&#xff0c;具体内容如下 对ExpandableListView控件进行封装(未自定义)直接上代码&#xff1a; 通用ViewHolder类&#xff0c;仅在setImageResource中添加代码 package com.svp.haoyan.ex…

android expandablelistview横向,expandableListView 总结

实现效果图&#xff1a; expandableListView groupIndicator 图片默认是在左边&#xff0c;而且比较难看&#xff0c;而我要的是实现groupIndicator 在右边自定义图片&#xff0c; 换图片 最简单的就是直接copy 系统 android:drawable/expander_group ?android:attr/expandab…

Android学习之ExpandableListView

什么是ExpandableListView ExpandableListView是扩展的ListView&#xff0c;继承自ListView&#xff1b;ExpandableListView可以实现点击展开列表&#xff0c;再点击收缩回去的效果。 ExpandableListView的使用 首先需要在主布局文件中声明ExpandableListView&#xff1b; …

ExpandableListView详解

文章目录 效果图ExpandableListView的简介与使用去掉ExpandableListView的箭头以及自定义Indicator解决setOnChildClickListener失效问题解决collapseGroup(i)崩溃问题解决group_item.xml中包含CheckBox、EditText等&#xff0c;点击不能展开的问题 1.效果图 2.ExpandableLi…

values_list()

转载&#xff1a;https://www.cnblogs.com/chenchao1990/p/5311531.html?utm_sourcetuicool&utm_mediumreferral

列表(lists)

Lists and the things you can do with them.Includes indexing(索引&#xff09;,slicing &#xff08;切片&#xff09;and mutating&#xff08;变异&#xff09;. 1.Python 中的列表表示有序的值序列。 以下是如何创建它们的示例&#xff1a; primes [2,3,5,7] #我们可以…

Android Preference API 用法--ListPreference(一)

一&#xff0e;ListPreference简介 我们都只知道SharedPreference非常适合于参数设置功能&#xff0c;在此处的preference 也是代表SharedPreference的意思&#xff0c;在SharedPreference中&#xff0c;我们可以迅速的将某些值保存进xml文件中&#xff0c;然后我们可以读取这…

android entries属性,ListPreference需要设置两个属性:android:entries和android:entryValues...

android:defaultValue"black" android:entries"array/setting_skintheme" android:entryValues"array/setting_skintheme_value" android:key"SkinTheme" android:summary"请选择您喜欢的软件皮肤颜色" android:title"…

Android ListPreference的用法

首先&#xff0c;我们明确&#xff0c;preference是和数据存储相关的。 其次&#xff0c;它能帮助我们方便的进行数据存储&#xff01;为什么这个地方一定要强调下方便的这个词呢&#xff1f;原因是&#xff0c;我们可以根本就不使用&#xff0c;我们有另外的N种办法可以实现同…