我试图在平板电脑上布局相对布局中的视图,非常像书架。将会有这么多,然后创建一个新的行。以编程方式在布局中布置子视图
我的初始状态是这样的:
<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