当前位置:首页 » 安卓系统 » androidbutton颜色设置

androidbutton颜色设置

发布时间: 2025-07-02 01:41:28

A. Android 当给一个button设置一个透明背景后 文字不见了 怎么解决

你可以把Button的background属性设为 “@null” 。 如果字不显示,就设置下字的颜色textColor

B. android 怎么动态设置button 的style

自定义样式方法,可以直接通过定义xml文件来实现不同的样式:
只需要修改button_style文件,同样三种状态分开定义:
Xml代码
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<gradient android:startColor="#0d76e1" android:endColor="#0d76e1"
android:angle="270" />
<stroke android:width="1dip" android:color="#f403c9" />
<corners android:radius="2dp" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
</item>

<item android:state_focused="true">
<shape>
<gradient android:startColor="#ffc2b7" android:endColor="#ffc2b7"
android:angle="270" />
<stroke android:width="1dip" android:color="#f403c9" />
<corners android:radius="2dp" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
</item>

<item>
<shape>
<gradient android:startColor="#000000" android:endColor="#ffffff"
android:angle="180" />
<stroke android:width="1dip" android:color="#f403c9" />
<corners android:radius="5dip" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
</item>
</selector>

gradient 主体渐变 startColor开始颜色,endColor结束颜色 ,angle开始渐变的角度(值只能为90的倍数,0时为左到右渐变,90时为下到上渐变,依次逆时针类推)
stroke 边框 width 边框宽度,color 边框颜色
corners 圆角 radius 半径,0为直角
padding text值的相对位置

C. android button点击前和点击中的颜色不同怎么设置,点击后要变回原来的颜色,只有按住的时候才变颜色

可以按楼上说的换背景图,或者就是在button的onclick事件同btn.setbackground里边设置颜色就好,如果只是换颜色的话,这个比较简单。

热点内容
cs15反脚本 发布:2025-09-21 04:24:01 浏览:824
微信零钱包密码怎么改 发布:2025-09-21 04:10:18 浏览:853
nginx整合php 发布:2025-09-21 04:01:56 浏览:1000
编译原理27答案 发布:2025-09-21 03:58:09 浏览:800
otc机器人试教器编程 发布:2025-09-21 03:56:12 浏览:580
代码生成脚本的作用 发布:2025-09-21 03:44:53 浏览:695
小蜜脚本设置监控 发布:2025-09-21 03:42:36 浏览:57
微信正在修复数据库 发布:2025-09-21 03:34:38 浏览:656
pythonhttp文件下载 发布:2025-09-21 03:30:26 浏览:777
行李箱上面的密码锁是干什么用的 发布:2025-09-21 03:30:25 浏览:928