0
我想在顯示器頂部創建一個水平線的小圖像縮略圖。他們應該從左邊排隊寫(全部左移)。當你點擊一個縮略圖時,它的較大版本應該顯示在這一行的下面。我決定採用水平LinearLayout(參見ID = galleryLayout)。它應該是LinearLayout,因爲我想稍後在HorizontalScrollView中使用它。這是我的佈局代碼:Android LinearLayout不會左對齊內容
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffef3a"
android:orientation="vertical"
tools:context=".Gallery01">
<LinearLayout
android:id="@+id/galleryLayout"
android:orientation="horizontal"
android:gravity="left"
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="#ffff3e34">
<ImageView
android:src="@drawable/pic02"
android:layout_gravity="left"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<ImageView
android:id="@+id/image1"
android:scaleType="fitXY"
android:layout_width="320dp"
android:layout_height="320dp" />
</LinearLayout>
但問題是,圖像顯示在佈局的中心,你可以在這裏看到:
正如你可以看到在重力LinearLayout不起作用,圖像在中心水平顯示。 ImageView本身的嚴重性不太好(這只是試圖使它工作!)。
你們有什麼想法我做錯了嗎?謝謝你的幫助!!