我正在努力嘗試在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