1、设置背景渐变效果,在drawable目录下建buttonshape.xml文件,

内容为:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:andro/> 
</shape>

这里startColor是开始颜色,endColor是渐变结束颜色,默认是从上往下渐变,可以使用android:centerY调节,android:angle="270"设置角度。

 

corners设置边角的圆滑度。

设置点中的效果,在drawable目录下建buttonshape_down.xml文件,内容如下:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:andro /> 
</shape>

在res目录下新建文件夹xml,然后在xml目录下,新建selectshape.xml文件,内容如下:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:andro/> 是否获得焦点状态
</selector>

设置了图片的触发状态,你可以设置 state_pressed,state_checked,state_pressed,state_selected,state_focused,state_enabled 等几个状态

state_pressed设置按钮状态,在main.xml文件中设置Button的属性:

<Button android: />

使用background设置按钮的背景色。

相关文章:

  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2021-09-07
  • 2022-02-07
  • 2022-12-23
猜你喜欢
  • 2021-11-18
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
相关资源
相似解决方案