【发布时间】:2019-01-03 10:47:05
【问题描述】:
我想为我的应用创建特殊视图。它是垂直虚线和上下两个半圆。有什么方法可以将其创建为可绘制的单一形状吗?我画了虚线,但我不能画半圈。
它应该看起来像这样。
垂直虚线:
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="90" android:toDegrees="90">
<shape
android:shape="line">
<stroke
android:color="#777777"
android:dashWidth="7dp"
android:dashGap="5dp"
android:width="2dp"/>
</shape>
</rotate>
我发现有人试图做半圈,但它很大。我只需要小圈子。它甚至不是圆。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:bottomLeftRadius="100000dp"
android:topLeftRadius="0dp"
android:bottomRightRadius="100000dp"
android:topRightRadius="0dp" />
<solid android:color="#777777" />
</shape>
【问题讨论】:
-
您也可以在形状中指定 size 属性以使其变小。
标签: android android-drawable android-shape