0
我创建了一个包含两个图像视图的XML文件。我想在每个视图的中心绘制两个不同的圆圈(不同的大小,颜色)。我该怎么做,特别是坐标。谢谢!在不同视图中绘制多个形状
我创建了一个包含两个图像视图的XML文件。我想在每个视图的中心绘制两个不同的圆圈(不同的大小,颜色)。我该怎么做,特别是坐标。谢谢!在不同视图中绘制多个形状
你可以做到这一点使用shape Drawables
...
创建您的Drawable
文件夹circle.xml
...
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<solid android:color="@android:color/transparent"/>
<corners android:radius="12px"/>
<stroke android:width="2dp" android:color="#000000"/>
</shape>
用它在你的ImageView
<ImageView android:id="@+id/circleimage"
android:layout_height="150dp"
android:layout_width="150dp"
android:src="@drawable/circle">
</ImageView>
你可以使用这个圈子.xml用于一个或多个imageViews ...
创建ImageView的子类。在XML中使用该子类。然后覆盖
public void draw(Canvas canvas){
super.draw(canvas);
// do your drawing here
// canvas holds the drawable area
// use canvas.drawXXXX methods with basic mathematics to put circles in places you need
}
希望这回答你的问题。