Android 如何用指针边缘画椭圆
我想画一个椭圆形的东西,上面有指向某个东西的指针。我如何通过Android中的形状实现它Android 如何用指针边缘画椭圆,android,android-shape,Android,Android Shape,我想画一个椭圆形的东西,上面有指向某个东西的指针。我如何通过Android中的形状实现它 如果我要这样做,我会使用IDE提供的9patch draw工具。但是,在XML中,我将定义一个可绘制的资源,其中可能包含以下代码: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item>
如果我要这样做,我会使用IDE提供的9patch draw工具。但是,在XML中,我将定义一个可绘制的资源,其中可能包含以下代码:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<size
android:width="100dp"
android:height="100dp" />
<solid android:color="#5EB888" />
<corners android:radius="0dp"/>
</shape>
</item>
<!-- default color for item at the top 5EB888 -->
<item
android:top="-40dp"
android:bottom="65dp"
android:right="-30dp">
<rotate
android:fromDegrees="45">
<shape android:shape="rectangle">
<solid android:color="#ffffff" />
</shape>
</rotate>
</item>
<item
android:top="65dp"
android:bottom="-40dp"
android:right="-30dp">
<rotate
android:fromDegrees="-45">
<shape android:shape="rectangle">
<solid android:color="#ffffff" />
</shape>
</rotate>
</item>
</layer-list>
只需将此绘图作为背景应用于小部件,您将得到一个指向的矩形。在你的情况下,你需要一个椭圆形。你可以根据自己的口味改变形状和大小。希望这有帮助。
将此代码应用于按钮小部件后得到的结果如下所示:
更多关于ListLayer xml元素的信息我认为您不能仅使用shape drawable,但使用自定义视图和其他drawable,您可以轻松完成。显而易见且简单的方法是使用可绘制资源。。