如何在安卓中制作表格有一张图片和 2 个文本视图



这是我的第一个问题,所以如果我问错了,请指导我。我想使用表格来显示游戏中具有图片、标题和简要描述的角色数量。单击角色后,用户将被转移到另一个视图中,在那里他可以看到有关该角色的更多详细信息。

假设您的布局可能包含TextView(Title) Table的第一行,带有ImageView(Your Picture)TextView(Brief Description)。您可以根据TableRow的要求使用android:weightSumandroid:layout_weight

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TableLayout 
    android:layout_height="fill_parent"
    android:layout_width="wrap_content"
    android:weightSum="3"
 >
    <TableRow 
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_weight="1"
        >
        <TextView 
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_span="2"
        android:text="Title"
            />
    </TableRow>
    <TableRow 
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_weight="2"
        >
        <ImageView 
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:src="drawable/...png"
            />
       <TextView 
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:text="Brief Description"
            />
    </TableRow>
  </TableLayout>
  </LinearLayout>

相关内容

最新更新