xPlace 在不同分辨率的背景图像上的固定点上编辑文本

xPlace EditText over fixed points on background image for different resulution

我正在 Android 中构建图层,为此我正在将背景图像加载到 ImageView 中,并在其上绘制一个小的迷你黑框,例如占位符。

我想知道如何在图像上的那些小点上设置一些 EditText,你看不到它们但是假设我必须在 bg 图像上加黑框并且我想放置他们是我的 text1text2。我尝试使用 RelativeLayout 并使用固定填充但是当更改屏幕尺寸或方向时它变得混乱,我读到最好的方法是通过检查屏幕分辨率并计算正确的时间将它们放在 运行 上每个 EditText 的尺寸,但我认为这是很多工作。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout
        android:id="@+id/background_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/bg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="@drawable/bg" />

            <TextView
                android:id="@+id/text1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"/>

   <TextView
                android:id="@+id/text2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"/>

        </RelativeLayout>
    </RelativeLayout>

这是图片,我想在结果和团队的黑框上放一些文字。

我有什么选择?

Android 设备尺寸变化很大 Android 你不能通过这样做获得完美,我建议你使用图像的纯背景并将那个小迷你框作为不同的图像并设置它作为 EditText 背景。

否则,您必须为每个出现差异的设备手动设置填充和边距。

希望对您有所帮助。