【发布时间】:2016-01-15 05:36:48
【问题描述】:
【问题讨论】:
标签: android android-xml android-drawable xml-drawable
【问题讨论】:
标签: android android-xml android-drawable xml-drawable
您可以使用以下XML 代码制作圆圈:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" >
<solid android:color="#c4bfbf"/>
</shape>
您可以将上述圆圈作为背景添加到视图中,并在该视图的顶部保留另一个视图,该视图可以是中心垂直的,XML 将是:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#FF0000" />
<padding android:bottom="1dp" android:left="10dp" android:right="10dp" android:top="1dp"/>
<corners
android:bottomRightRadius="20dp"
android:bottomLeftRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp"/>
</shape>
以编程方式绘制圆圈,您可以使用这种方式,这对我有用
ShapeDrawable biggerCircle= new ShapeDrawable( new OvalShape());
biggerCircle.setIntrinsicHeight( 60 );
biggerCircle.setIntrinsicWidth( 60);
biggerCircle.setBounds(new Rect(30, 30, 30, 30));
biggerCircle.getPaint().setColor(Color.parseColor(first));//give any color here
holder.firstcolor.setBackgroundDrawable(biggerCircle);
【讨论】:
我已经创建了类似的形状,其中外部灰色圆圈包含内部红色圆圈。代码如下:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<solid android:color="#E84F3D" />
<stroke
android:width="15dp"
android:color="#BEBEBE" />
</shape>
【讨论】: