android xml中的单侧成角矩形
是否有任何方法可以在android xml中绘制单侧有角度的矩形。就像下面的图片android xml中的单侧成角矩形,android,xml,Android,Xml,是否有任何方法可以在android xml中绘制单侧有角度的矩形。就像下面的图片 可以使用以下xml代码实现。唯一的缺点是第二个矩形应该与背景颜色匹配 <?xml version="1.0" encoding="UTF-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <!-- Colored rectangle-->
可以使用以下xml代码实现。唯一的缺点是第二个矩形应该与背景颜色匹配
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Colored rectangle-->
<item>
<shape android:shape="rectangle">
<size
android:width="100dp"
android:height="40dp" />
<solid android:color="#F00" />
</shape>
</item>
<!-- Overlay with same color as background-->
<item
android:top="20dp"
android:bottom="-40dp"
android:right="-30dp">
<rotate
android:fromDegrees="-60">
<shape android:shape="rectangle">
<solid android:color="#FFF" />
</shape>
</rotate>
</item>
</layer-list>
不要为此使用xml,这是毫无意义的,而是使用一个带有自定义形状的ShapeDrawable
类请原谅,但该形状在我的屏幕上不会显示为矩形,而是显示为四边形,其中两条边平行,两个角为直角。