我正在努力尝试在Android中同时创建水平和垂直堆叠的图像。我尝试了一堆不同的方法,但似乎无法达到目标。我会上传一个我要去的图片,但是没有stackoverflow点,所以这里是我的代码。希望你们能帮我阻止我的头靠在墙上。除非我仍然关于这个完全错误,似乎我的问题是在最后一个相对布局 - 我不允许有一个相对布局是在LinearLayout中的特定对象的权利?此外,我如何做到这一点,而不在我的图像重叠?:如何在Android中创建水平和垂直堆叠的图像?
编辑,显示代码tableLayout:
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:xlmns="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity$PlaceholderFragment">
<TextView android:id="@+id/section_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TableRow
android:id="@+id/tableRow1Buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:layout_column="0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FILTER"
android:id="@+id/filterButton"
/>
<Button
android:layout_column="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Neighborhood?"
android:id="@+id/neighborhoodButton"
/>
</TableRow>
<TableRow
android:id="@+id/tableLayoutListing1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_column="0"
android:layout_width="0dp"
android:layout_weight=".70"
android:layout_height="300dp"
android:id="@+id/listingImage1"
android:src="@drawable/alex_room"
android:layout_gravity="top" />
<ImageView
android:layout_column="1"
android:layout_width="0dp"
android:layout_weight=".30"
android:layout_height="100dp"
android:id="@+id/listingImage2"
android:src="@drawable/alex_room_two"
android:layout_gravity="top" />
<ImageView
android:layout_toRightOf="@+id/listingImage1"
android:layout_below="@+id/listingImage2"
android:layout_width="0dp"
android:layout_weight=".30"
android:layout_height="100dp"
android:id="@+id/listingImage3"
android:src="@drawable/livingroom"
android:layout_gravity="bottom" />
</TableRow>
</TableLayout>
为什么不把它放在一个相对的布局?线性布局使得代码更快速,但对于复杂的布局,相对布局更加灵活。 – maxib7