如何在android drawable中绘制下面提到的圆角形状

如何在android drawable中绘制下面提到的圆角形状,android,Android,我已经尝试过该代码,但似乎不正确,请帮助 <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <rotate android:fromDegrees="45" android:pivotX="35%" android:pivotY="30%"> <shape&

我已经尝试过该代码,但似乎不正确,请帮助

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
<rotate
android:fromDegrees="45"
android:pivotX="35%"
android:pivotY="30%">
<shape>
<size android:height="5dp" android:width="5dp"/>
<corners android:radius="0.5dp" />
<solid android:color="@color/white" />
</shape>
</rotate>
</item>


使用矢量绘图可能更容易:


如果需要进行一些调整,应该下载Inkscape()或其他svg设计软件和我的源文件(如果需要)。绘制图形,然后在svg中再次导出。一旦您有了svg格式的文件,您就可以使用Android Studio中的矢量资产工具。该工具会自动生成矢量xml,您可以将矢量可绘制文件用作公共可绘制文件,例如用作ImageView的源文件。希望有帮助


<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <!-- view background color -->
    <solid
        android:color="#142737" >
    </solid>

    <!-- Here is the corner radius -->
    <corners
        android:radius="10dp"   >
    </corners>
将此xml文件放在drawable文件夹中,并将其设置为按钮的背景,如:

android:background=“@drawable/oval\u background”

使用
ShapeDrawable
将自定义
Shape
对象传递给
ShapeDrawable
构造函数。我认为最好的方法是使用svg文件中的向量drawable(可能使用Inkscape/adobe illustrator创建/编辑)并作为drawable导入。您尝试过我的解决方案吗?
<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <!-- view background color -->
    <solid
        android:color="#142737" >
    </solid>

    <!-- Here is the corner radius -->
    <corners
        android:radius="10dp"   >
    </corners>