Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在ImageView上使用EditText_Android_Xml_Android Layout - Fatal编程技术网

Android 如何在ImageView上使用EditText

Android 如何在ImageView上使用EditText,android,xml,android-layout,Android,Xml,Android Layout,我正在制作一个应用程序,其中我必须在一个XML文件中使用两个图像。一个是标志,另一个是一些登录模式。在模式图像上,我必须设置两个EditText。我该怎么做 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_p

我正在制作一个应用程序,其中我必须在一个XML文件中使用两个图像。一个是标志,另一个是一些登录模式。在模式图像上,我必须设置两个EditText。我该怎么做

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >
<ImageView
.
.
.
.
./>

          <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="@drawable/some image" 
            android:layout_marginLeft="200dp"
            android:layout_marginBottom="300dp"
            android:layout_marginTop="80dp">  

           <LinearLayout 
            android:layout_height="fill_parent"
            android:layout_width="fill_parent" 
            android:layout_weight="1"
            android:gravity="center" 
            android:orientation="vertical">
            <EditText 
             android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
                           />
        </LinearLayout>
    </RelativeLayout>
    </relativeLayout>

您的问题有点模糊,但您可以轻松地使用它将编辑文本放置在ImageView上方

一个基本的例子是:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/image" />

</RelativeLayout>

要将edittext放置在imageview上方,请执行以下操作:

EditText edit = (EditText)findViewById(R.id.YOUR_EDITTEXT_ID);
ImageView image = (ImageView)findViewById(R.id.YOUR_IMAGEVIEW_ID);
image.setImageBitmap(YOUR_BITMAP);
edit.bringToFront();

上述代码将使编辑文本沿z轴位于imageview上方。当然,您必须以XML或编程方式定位它们。

如果我理解正确,您基本上希望有一个背景,前景中有两个EditText

最好的方法是通过相对布局。注意,这是伪代码,所以不能直接工作

<RelativeLayout>

    <ImageView
        android:height="fill_parent"
        android:src="@drawable/some_image"
        android:width="fill_parent" />

    <EditText
        android:id="@+id/edit_text1"
        android:layout_alignParentBottom="true" />

    <EditText
        android:id="@+id/edit_text2 "
        android:layout_above="@id/edit_text1" />

</RelativeLayout>

谢谢大家的帮助。我已经完成了我的任务。这个应用程序是针对平板电脑的,所以请根据这一点修改margines。这是密码

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

<ImageView
    android:id="@+id/login"
    android:layout_width="648dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="640dp"
    android:layout_marginTop="40dp"
    android:src="@drawable/ic_login" />

<EditText 
    android:id="@+id/et1"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:cursorVisible="true"
    android:background="#000"
    android:singleLine="true"
    android:layout_marginTop="100dp"
    android:layout_marginLeft="710dp"
    android:layout_marginRight="193dp"
    android:textColor="#fff"/>

<EditText 
    android:id="@+id/et1"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:cursorVisible="true"
    android:background="#000000"
    android:singleLine="true"
    android:layout_marginTop="127dp"
    android:layout_marginLeft="710dp"
    android:layout_marginRight="193dp"
    android:textColor="#fff"/>

<ImageView 
     android:id="@+id/logo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="420dp"
    android:layout_marginLeft="2dp"
    android:src="@drawable/ic_glogo" />


 </RelativeLayout> 

你想要一些背景以上的编辑文本吗?是的。。。2登录ID和Passwrdplz的编辑文本最后查看我的代码,并告诉我是否这样做正确??抱歉,我无法回答我的问题,因为我没有太多的声誉...'单击问题左下角的“编辑”在此处添加代码。完成。。。请检查代码实际上,XML中没有一个图像。。同一XML中有两个图像。一个在右上角,另一个在左下角。所以我想在右上角的图片中设置编辑文本..更简单。您可以将编辑文本对齐到右上角的图像中。thnx brother。。我得到了结果