彩色按钮上的状态列表形状?

彩色按钮上的状态列表形状?,第1张

概述我有一个这样的状态列表:<selectorxmlns:android="http://schemas.android.com/apkes/android"><itemandroid:state_pressed="true"android:drawable="@color/dark_green"/><itemandroid:drawable=&quo

我有一个这样的状态列表:

<selector xmlns:androID="http://schemas.androID.com/apk/res/androID">    <item        androID:state_pressed="true"        androID:drawable="@color/dark_green" />    <item androID:drawable="@color/bright_green" /></selector>

像这样的形状(用于使按钮变圆):

<?xml version="1.0" enCoding="utf-8"?><shape xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:shape="rectangle">    <corners androID:bottomrighTradius="7dp" androID:bottomLefTradius="7dp" androID:topLefTradius="7dp" androID:topRighTradius="7dp"/> </shape>

我的问题是如何同时应用两者?如果我将backgroundResource设置为颜色列表,则可以获取颜色,但是无法将其用于形状.我尝试将backgroundResource用作形状,并将backgroundcolor用作颜色,但这没有用.

解决方法:

<selector xmlns:androID="http://schemas.androID.com/apk/res/androID">    <item        androID:state_pressed="true"        androID:drawable="@color/dark_green" >        <shape androID:shape="rectangle">           <corners androID:bottomrighTradius="7dp"                     androID:bottomLefTradius="7dp"                     androID:topLefTradius="7dp"                     androID:topRighTradius="7dp"/> </shape>    <item/>    <item androID:drawable="@color/bright_green" /></selector>

我已经做过类似your.的事情,但是当您使用draDWalbe时,它不起作用.如果您这样使用(使用实心填充按钮而不使用可绘制对象,可以拖动圆角按钮),则可以使用.

<?xml version="1.0" enCoding="utf-8"?><@R_118_3419@ xmlns:androID="http://schemas.androID.com/apk/res/androID">   <item>             <shape androID:shape="rectangle">          <solID androID:color="#FFEC7600" />         <corners                        androID:topLefTradius="5dip"                androID:topRighTradius="5dip"                androID:bottomLefTradius="5dip"                androID:bottomrighTradius="5dip" />      </shape>   </item>

总结

以上是内存溢出为你收集整理的彩色按钮上的状态列表形状?全部内容,希望文章能够帮你解决彩色按钮上的状态列表形状?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1070169.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存