我試圖在平板電腦上佈局相對佈局中的視圖,非常像書架。將會有這麼多,然後創建一個新的行。以編程方式在佈局中佈置子視圖
我的初始狀態是這樣的:
<ScrollView
android:layout_marginTop="150sp"
android:layout_marginLeft="50sp"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id="@+id/user_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- Add User Avatar -->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/user_frame" />
<ImageView
android:id="@+id/demo_image"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/add_user"
android:layout_marginLeft="10px" />
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/user_name_background"
android:layout_marginLeft="10px" />
<TextView
android:id="@+id/user_name"
android:layout_width="180px"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold"
android:gravity="center_horizontal"
android:text="Add New User" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
我取的記錄從數據庫中,併爲每個記錄我需要放置一個版本的「添加用戶阿凡達」部分的由上述可見。我想做5,然後換行到新行。
我最初的想法是使用佈局inflater並以編程方式添加視圖,使用RelativeLayout.LayoutParams來設置layout_toRightOf值。
雖然必須有一個更簡單的方法。我見過很多使用「書架」隱喻的應用程序。
我的第一個多達五個鏡像視圖的水平佈局以爲會使用GridView。 – kcoppock