Android 如何创建可绘制的圆?

Android 如何创建可绘制的圆?,android,drawable,android-drawable,Android,Drawable,Android Drawable,如何创建一个带有5像素蓝色笔划和透明填充的圆的可绘制的 我将把这个drawable传递给ItemizedOverlay 我想用代码来实现这一点,我将知道圆的半径。尝试以下方法: <shape xmlns:android="http://schemas.android.com/apk/res/android" type="OvalShape" > <stroke android:width="5dp" android:color="#99104E8B"/&g

如何创建一个带有5像素蓝色笔划和透明填充的圆的
可绘制的

我将把这个
drawable
传递给
ItemizedOverlay


我想用代码来实现这一点,我将知道圆的半径。

尝试以下方法:

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
       type="OvalShape" >
   <stroke android:width="5dp" android:color="#99104E8B"/>
   ....
</shape>

....
只需将类似的内容放入drawables目录中的XML文件中,并像加载普通图像一样加载它


请参阅Android文档中的ShapeDrawable。

尝试以下内容:

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
       type="OvalShape" >
   <stroke android:width="5dp" android:color="#99104E8B"/>
   ....
</shape>

....
只需将类似的内容放入drawables目录中的XML文件中,并像加载普通图像一样加载它


请参阅Android文档中的ShapeDrawable。

这似乎是最好的主意,我想我可以在运行时更改边界。是的,您可以。你在应用程序中加载它的方式与加载图像的方式相同。可以通过setBound()方法设置边界。查看文档。上面的答案中似乎有一个类型:它应该是
android:type=“oval”
而不是
type=OvalShape“
关于此答案的所有内容都不正确,应该删除。这似乎是最好的主意,然后我可以在运行时更改边界。是的,您可以。你在应用程序中加载它的方式与加载图像的方式相同。可以通过setBound()方法设置边界。查看文档。上面的答案中似乎有一个类型:它应该是
android:type=“oval”
而不是
type=OvalShape”
关于这个答案的所有内容都不正确,应该删除它。