我尝试使用此代码,但它不适用于所有维度屏幕。有没有其他方法可以做到这一点。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="@drawable/diabetic_foot_left"
android:layout_alignParentLeft="true" />
</Linear layout>
<View
android:id="@+id/view_lf_sensatiion1green"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="72dp"
android:layout_marginTop="150dp"
android:background="@drawable/circle_green"
android:layout_alignParentLeft="true"
android:layout_marginLeft="60dp"
/>
</LinearLayout>
circle_green.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:layout_width="1dp"
android:layout_height="1dp">
<solid
android:color="#00ff00"/>
<size
android:width="2dp"
android:height="2dp"/>
</shape>
&#13;
我想在图像上放置点,如下所示
我尝试使用此代码,但它不适用于所有维度屏幕。有没有其他方法可以做到这一点。请帮助我,我是新手。
答案 0 :(得分:1)
我建议查看Canvas。您可以动态地在其他图像上绘制图像,创建custom drawings
类似的东西:
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
Bitmap foot = BitmapFactory.decodeResource(getResources(), R.drawable.diabetic_foot_left);
image = Bitmap.createScaledBitmap(temp, canvas.getWidth(), canvas.getHeight(), true);
canvas.drawBitmap(image, 0, 0, null);
Bitmap over = BitmapFactory.decodeResource(getResources(), R.drawable.circle_green);
image = Bitmap.createScaledBitmap(over, canvas.getWidth(),
canvas.getHeight(), true);
canvas.drawBitmap(image, 0, 0, null);
}
答案 1 :(得分:0)
即使我在我的项目中有相同的要求。这就是我解决的方法。
我希望这对少数人有帮助。