Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中使用xml绘制图形_Android_Android Xml_Android Drawable_Xml Drawable - Fatal编程技术网

如何在android中使用xml绘制图形

如何在android中使用xml绘制图形,android,android-xml,android-drawable,xml-drawable,Android,Android Xml,Android Drawable,Xml Drawable,需要使用xml绘制以下圆形,红色形状 是否可以仅使用xml绘制此圆?要以编程方式绘制圆,您可以使用这种方式,这对我很有用 ShapeDrawable biggerCircle= new ShapeDrawable( new OvalShape()); biggerCircle.setIntrinsicHeight( 60 ); biggerCircle.setIntrinsicWidth( 60);

需要使用xml绘制以下圆形,红色形状


是否可以仅使用xml绘制此圆?

要以编程方式绘制圆,您可以使用这种方式,这对我很有用

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>

可以使用以下XML代码创建圆:

你能帮我吗
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" >
<solid android:color="#c4bfbf"/>
</shape>
<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>