我想让我的Android布局在顶部有两个ImageViews,每个都占据水平空间的一半,并且在两个图像视图下面共有3个按钮,如下图所示。
[imageview的] [ImageView的]
[butn1] [butn2] [butn3]
但是,两个图像视图都被限制在butn1的右侧,就像这样
[I1] [12]
[butn1] [butn2] [butn3]
我的代码如下。
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/background_dark"
android:orientation="horizontal"
android:stretchColumns="*" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="9" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<ImageView
android:id="@+id/boobs_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<ImageView
android:id="@+id/kittens_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:adjustViewBounds="true" />
</RelativeLayout>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<Button
android:id="@+id/save_boobs_internal_storage_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "Save titties"
style="@style/ButtonTheme" />
<Button
android:id="@+id/next_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "Next"
style="@style/ButtonTheme" />
<Button
android:id="@+id/save_kitty_internal_storage_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "Save kitty"
style="@style/ButtonTheme" />
</TableRow>
</TableLayout>
答案 0 :(得分:1)
我想通了
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/background_dark" >
<LinearLayout
android:id="@+id/imagesLinearLayout"
android:orientation="horizontal"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<ImageView
android:id="@+id/boobs_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<ImageView
android:id="@+id/kittens_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:adjustViewBounds="true" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/buttonLinearLayout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="bottom" >
<Button
android:id="@+id/save_boobs_internal_storage_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text = "Save titties"
style="@style/ButtonTheme" />
<Button
android:id="@+id/next_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text = "Next"
style="@style/ButtonTheme" />
<Button
android:id="@+id/save_kitty_internal_storage_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text = "Save kitty"
style="@style/ButtonTheme" />
</LinearLayout>
</RelativeLayout>
答案 1 :(得分:0)
尝试修改后的布局:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/background_dark"
android:orientation="horizontal"
android:stretchColumns="*" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<ImageView
android:id="@+id/boobs_image_view"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"/>
<ImageView
android:id="@+id/kittens_image_view"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="9" >
<Button
android:id="@+id/save_boobs_internal_storage_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:text = "Save titties"
style="@style/ButtonTheme" />
<Button
android:id="@+id/next_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:text = "Next"
style="@style/ButtonTheme" />
<Button
android:id="@+id/save_kitty_internal_storage_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:text = "Save kitty"
style="@style/ButtonTheme" />
</TableRow>
</TableLayout>