Android使图像前置分层

时间:2015-06-12 16:45:33

标签: android

我是Android开发的新手,我遇到了布局的一个小问题,我的图像在文本框下面,所以我无法真正看到图像,任何人都可以帮助我。

1 个答案:

答案 0 :(得分:1)

只需更改XML布局中的顺序:

由此:(在本例中为EditText下的图像):

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/your_img"/>
<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="text"/>

到此:( EditText上方的图像):

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="text"/>    
<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/your_img"/>