垂直布局或 GridLayout 中的水平布局
Horizontal Layout Inside a Vertical Layout or GridLayout
我是 android 编程的新手,想知道是否有人可以帮助提供任何信息或 link 或代码来帮助我创建下面的图像。
Final OutCome
尝试下面的代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="line e" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
使用table布局这里是示例
<RelativeLayout android:layout_width="match_parent"
android:orientation="vertical"
android:paddingTop="5dp"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TableLayout
android:layout_width="match_parent"
android:id="@+id/tableHead"
android:layout_height="wrap_content">
<TableRow
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:focusable="true"
android:focusableInTouchMode="false"
android:clickable="true">
<TextView
android:text="S.No"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_column="1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Date"
android:layout_weight="1"
android:gravity="center"
android:layout_column="2" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Count"
android:layout_weight="1"
android:gravity="center"
android:layout_column="3" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:focusable="true"
android:focusableInTouchMode="false"
android:clickable="true"
android:background="@android:drawable/list_selector_background">
<TextView
android:text="S.No"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_column="1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Date"
android:layout_weight="1"
android:gravity="center"
android:layout_column="2" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Count"
android:layout_weight="1"
android:gravity="center"
android:layout_column="3" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:focusable="true"
android:focusableInTouchMode="false"
android:clickable="true">
<TextView
android:text="S.No"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_column="1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Date"
android:layout_weight="1"
android:gravity="center"
android:layout_column="2" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Count"
android:layout_weight="1"
android:gravity="center"
android:layout_column="3" />
</TableRow>
</TableLayout>
</RelativeLayout>
我是 android 编程的新手,想知道是否有人可以帮助提供任何信息或 link 或代码来帮助我创建下面的图像。
Final OutCome
尝试下面的代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="line e" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line e" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
使用table布局这里是示例
<RelativeLayout android:layout_width="match_parent"
android:orientation="vertical"
android:paddingTop="5dp"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TableLayout
android:layout_width="match_parent"
android:id="@+id/tableHead"
android:layout_height="wrap_content">
<TableRow
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:focusable="true"
android:focusableInTouchMode="false"
android:clickable="true">
<TextView
android:text="S.No"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_column="1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Date"
android:layout_weight="1"
android:gravity="center"
android:layout_column="2" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Count"
android:layout_weight="1"
android:gravity="center"
android:layout_column="3" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:focusable="true"
android:focusableInTouchMode="false"
android:clickable="true"
android:background="@android:drawable/list_selector_background">
<TextView
android:text="S.No"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_column="1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Date"
android:layout_weight="1"
android:gravity="center"
android:layout_column="2" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Count"
android:layout_weight="1"
android:gravity="center"
android:layout_column="3" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:focusable="true"
android:focusableInTouchMode="false"
android:clickable="true">
<TextView
android:text="S.No"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_column="1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Date"
android:layout_weight="1"
android:gravity="center"
android:layout_column="2" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Count"
android:layout_weight="1"
android:gravity="center"
android:layout_column="3" />
</TableRow>
</TableLayout>
</RelativeLayout>