如何用 xml 在 Android 中创建这个特定的形状?
How to create this particular shape with xml in Android?
我想创建一个形状,如下图所示,但我想用 XML 代码(可绘制)创建这个 而我 不想要用9.patch张图片创建这个!
如何使用 xml 代码创建此形状?
这是一个解决方法
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#FFFFFF"/>
<corners
android:bottomRightRadius="0dp"
android:bottomLeftRadius="0dp"
android:topLeftRadius="15dp"
android:topRightRadius="15dp"/>
</shape>
调整拐角半径,让你的上半身弯曲!
或重叠这个椭圆形以获得所需的输出
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<!--circle filling color-->
<solid android:color="#ffffff" />
<stroke
<!--radious can define in here-->
android:width="1dp"
android:color="#ffffff" />
<corners
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp" />
</shape>
但基本上,这不是正确的方法!使用另一种方法,使用 9 patch
我想创建一个形状,如下图所示,但我想用 XML 代码(可绘制)创建这个 而我 不想要用9.patch张图片创建这个!
如何使用 xml 代码创建此形状?
这是一个解决方法
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#FFFFFF"/>
<corners
android:bottomRightRadius="0dp"
android:bottomLeftRadius="0dp"
android:topLeftRadius="15dp"
android:topRightRadius="15dp"/>
</shape>
调整拐角半径,让你的上半身弯曲!
或重叠这个椭圆形以获得所需的输出
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<!--circle filling color-->
<solid android:color="#ffffff" />
<stroke
<!--radious can define in here-->
android:width="1dp"
android:color="#ffffff" />
<corners
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp" />
</shape>
但基本上,这不是正确的方法!使用另一种方法,使用 9 patch