Android的 - 多种颜色和放大器;大小绘制外形风格 [英] Android - Multiple colors & size in drawable shape style
问题描述
我想为我的TextView一个圆圈的背景,所以我创建了一个外形风格如下。
但是我需要有多种颜色有多种尺寸(而TEXTSIZE保持不变),所以我需要设置宽度/高度的风格。
I'm trying to have a circle background for my TextView, so I created a shape style as below. But I need to have multiple colors with multiple sizes (while the textSize stays constant), so I need to set the width/height in the style.
从我的理解.. 层列表看跌期权所有在彼此顶部的形状?因为我需要调用它的12倍在不同的地方,所以它似乎很繁琐的有12外形风格XML的。
From my understanding..Layer List puts all the shapes on top of one another? Because I need to call it 12 times at different places, so it seems quite cumbersome to have 12 shape style xmls.
有没有更好的办法有各种不同的形状/大小组合中的一个XML里面呢?
Is there a better way to have all the different shape/size combinations inside one XML?
形状样式:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<corners android:radius="10dp"/>
<solid android:color="@color/girl_orange"/>
<size
android:width="84dp"
android:height="84dp" />
</shape>
在布局XML中调用:
Called in layout xml by:
android:background="@drawable/skills_circle"
在此先感谢!
推荐答案
创建一个自定义绘制对象,这样你可以有大小/颜色的milions组合:
create a custom Drawable, this way you can have milions combinations of size/color:
class CircleDrawable extends Drawable {
...
}
这篇关于Android的 - 多种颜色和放大器;大小绘制外形风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!