我是 android 开发的新手,对布局设计有一些疑问。我有以下代码,但它没有按我想要的那样工作。我想让 ImageView 显示我拍摄的照片,并在其下方显示一个供用户输入数据的文本框。然而,此刻,图像占据了整个屏幕,我找不到我的文本框。请指教。谢谢!
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/linear">
<ImageView android:id="@+id/imageView1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:contentDescription="@string/desc"/>
<EditText
android:id="@+id/editTextSimple1"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<requestFocus />
</EditText>
</LinearLayout>
最佳答案
使用 RelativeLayout 代替 LinearLayout 并使用下面的 xml 代码代替您的 xml 代码,它将解决您的问题。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linear"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/editTextSimple1"
android:contentDescription="desc" />
<EditText
android:id="@+id/editTextSimple1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<requestFocus />
</EditText>
</RelativeLayout>
关于安卓布局( TextView ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13836814/