我尝试使用该代码,但似乎不正确,请帮助
<?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>
答案 0 :(得分:1)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners
android:topLeftRadius="12dp"
android:topRightRadius="12dp"
android:bottomLeftRadius="75dp"
android:bottomRightRadius="9dp"
/>
<gradient
android:angle="45"
android:centerX="35%"
android:centerColor="#47A891"
android:startColor="#E8E8E8"
android:endColor="#000000"
android:type="linear"
/>
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
/>
<size
android:width="100dp"
android:height="100dp"
/>
<stroke
android:width="3dp"
android:color="#878787"
/>
</shape>
答案 1 :(得分:0)
使用向量drawable可能会更容易:
<vector android:height="24dp" android:viewportHeight="101.01621"
android:viewportWidth="114.45102" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#00000000"
android:pathData="m0.421,7.319c-0.848,-4.225 2.893,-6.292 4.701,-6.534l93.265,-0.552c9.395,-0.736 15.906,2.42 15.875,15.875l-0.032,78.398c1.262,7.668 -11.009,7.894 -15.926,3.48 -17.528,-8.582 -70.939,-31.855 -92.048,-40.468 -1.899,-0.775 -3.147,-1.13 -4.14,-1.522 -2.225,-0.879 -2.097,-3.281 -1.851,-5.335z"
android:strokeAlpha="1" android:strokeColor="#000000"
android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="0.26458332"/>
</vector>
如果需要进行一些调整,请阻止下载Inkscape(https://inkscape.org)或其他svg设计软件以及我的源文件(如果需要)https://drive.google.com/open?id=1vY8tYcA00KAQeoulMlPmwvRWrs7EY672。绘制形状,然后再次将其导出为svg。将文件转换为svg格式后,即可使用Android Studio中的矢量资产工具。该工具会自动生成矢量xml,并且您可以将矢量可绘制对象用作普通可绘制对象,例如,用作ImageView的源。希望对您有帮助!
答案 2 :(得分:0)
<?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_background”