<selector>
和有什么区别和<shape>
在安卓中?何时使用<selector>
,和<shape>
?
最佳答案
What is the difference between
<selector>
and<shape>
in android?
除了布局资源中使用 XML 之外,它们不相关。
When to use
<selector>
, and<shape>
?
<shape>
是定义 a ShapeDrawable
的一种方法在可绘制资源中,用于表示具有各种边框和填充的矩形和椭圆形。
<selector>
是定义 a StateListDrawable
的一种方法在可绘制资源中,用于根据应用此 StateListDrawable
的小部件的状态指示要使用的其他可绘制对象.
因此,在按钮的上下文中,<selector>
会说明正常背景、按下背景、禁用背景等使用什么。 <shape>
将用于提供其中一个州的实际背景。
您可以在the documentation中阅读有关不同可绘制资源类型的更多信息。 .
关于android - android中<selector>和<shape>有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57101283/