Android 将编辑文本放在背景图像的固定点上,以获得不同的结果

Android 将编辑文本放在背景图像的固定点上,以获得不同的结果,android,android-layout,Android,Android Layout,我在Android中构建层,为此我将背景图像加载到ImageView中,并在其上绘制一个小的迷你黑框,如占位符 我想知道如何在图像上的那些小点上设置一些EditText,你看不到它们,但假设我必须在bg图像上用黑匣子'x,我想在它们上面放置我的text1,text2。我尝试使用RelativeLayout并使用固定的填充,但当更改屏幕大小或方向时会变得混乱,我读到最好的方法是在运行时检查屏幕分辨率并为每个EditText计算正确的大小,但我认为这需要做很多工作 <?xml version=

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

我想知道如何在图像上的那些小点上设置一些
EditText
,你看不到它们,但假设我必须在bg图像上用黑匣子'x,我想在它们上面放置我的
text1
text2
。我尝试使用
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>

这是图像,我想在结果和团队的黑框中添加一些文本。


我有什么选择?

安卓系统的设备尺寸变化很大,这样做是不可能做到完美的,我建议您使用图像的纯背景,并将小的迷你框作为不同的图像,并将其设置为
EditText
背景

另一方面,您必须手动设置每个设备的边距和边距,以获得差异


我希望这将对您有所帮助。

请共享您的xml文件您的背景图像是否有更改???@user3676184我添加了layout@Crazy没有背景没有改变,只有文字在上面EditText@AlexOpent感谢您分享代码。现在告诉我你的黑匣子图像大小是指它占据整个屏幕还是半屏幕。或者只需做一件事,给我发送静态屏幕截图,我在其中添加了文字,我不想为每个设备设置文字,我正在寻找一种在通用计算机上实时执行的方法mode@AlexOpent我建议您拍摄一个完整的黑盒背景,并在切片中拍摄其他图像,并将其设置为线性布局或相对布局中的图像,以方便为准。