Android Table 创作
Android Table Creation
如何在 android 中创建如下所示的 table:
-------------------------------
| | Text |
| picture |----------------
| | Text |
-------------------------------
使用 TableLayout,它就是为此而设计的。
阅读 this 教程,它详细描述了操作方法。
简而言之,TableLayout 允许 table 布局,这正是您所描述的。
table 中的每个元素本身就是一个视图,因此您可以获得最大的灵活性。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1.00"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
请根据需要设置权重
如何在 android 中创建如下所示的 table:
-------------------------------
| | Text |
| picture |----------------
| | Text |
-------------------------------
使用 TableLayout,它就是为此而设计的。
阅读 this 教程,它详细描述了操作方法。
简而言之,TableLayout 允许 table 布局,这正是您所描述的。
table 中的每个元素本身就是一个视图,因此您可以获得最大的灵活性。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1.00"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
请根据需要设置权重