Android 我怎样才能解决这个问题?
我希望看到以下布局工作:Android 我怎样才能解决这个问题?,android,layout,Android,Layout,我希望看到以下布局工作: -------------------------- | ----------- | | |TextView1| | | ----------- | | ---------------------- | | |EditText1 | | | ---------------------- | | ----------- | | |TextView2|
--------------------------
| ----------- |
| |TextView1| |
| ----------- |
| ---------------------- |
| |EditText1 | |
| ---------------------- |
| ----------- |
| |TextView2| |
| ----------- |
| ---------------------- |
| |EditText2 | |
| ---------------------- |
| ----------- |
| |TextView3| |
| ----------- |
| ---------------------- |
| | | |
| | | |
| | | |
| | ImageView | |
| | | |
| | | |
| | | |
| |--------------------| |
| --------- -------- |
| |Button1||Button2| |
| --------- -------- |
| ---------------------| |
| | ButtonBar | |
| ---------------------- |
|------------------------|
我的问题:我不能让Button1和Button2在这个布局中工作。它们要么位于ImageView下方,隐藏在按钮栏后面,要么在ImageView底部和按钮栏顶部之间收缩为零
当前XML代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/footer" >
<TextView
android:id="@+id/textPostUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="user" />
<EditText
android:id="@+id/editPostUser"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textPostUser"
android:hint="user"
android:maxLength="40" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textPostComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/editPostUser"
android:text="comment" />
<EditText
android:id="@+id/editPostComment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textPostComment"
android:hint="comment"
android:maxLength="200"
android:maxLines="3" >
</EditText>
<TextView
android:id="@+id/textPostCharacterCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/editPostComment"
android:text="characters"
android:textSize="5pt" />
<ImageView
android:id="@+id/imagePostResult"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/textPostCharacterCount"
android:src="@drawable/camera_icon" />
<Button
android:id="@+id/buttonPostRotateLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@id/imagePostResult"
android:text="left" />
<Button
android:id="@+id/buttonPostRotateRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@id/imagePostResult"
android:layout_toRightOf="@id/buttonPostRotateLeft"
android:text="right" />
</RelativeLayout>
<LinearLayout
android:id="@+id/footer"
style="@android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<Button
android:id="@+id/buttonPostSave"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="save" />
</LinearLayout>
</RelativeLayout>
如何使左/右按钮显示在图像视图下方和按钮栏上方?
我希望至少在ImageView的高度/宽度中保留填充父对象,因为它在不同分辨率下可以很好地缩放。为什么不将这两个按钮放在水平线性布局中?您的按钮设置为
android:layout\u alignParentBottom=“true”
。后者将隐藏前者,因为它在xml代码中是最后一个
尝试将按钮放置在线性布局中,并将其与页脚对齐
android:layout_over=“@+id/footer”
您的图像视图设置为填充父视图,因此下面的按钮没有空间。您可以切换按钮和imageview,以便imageview占据按钮已包含时的所有剩余空间:
<Button
android:id="@+id/buttonPostRotateLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="left" />
<Button
android:id="@+id/buttonPostRotateRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@id/buttonPostRotateLeft"
android:text="right" />
<ImageView
android:id="@+id/imagePostResult"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/buttonPostRotateLeft"
android:layout_below="@id/textPostCharacterCount"
android:src="@drawable/camera_icon" />
太完美了!我接受了这个答案,同时我也学到了一些东西。+1只是因为你做了很好的格式:)