如何在纵向设置/缩小 table 行大小?
How to set / shrink table row size in portrait?
如何在纵向设置 table 行宽和大小?我更喜欢它在横向视图中的外观。有没有办法让我缩小 "Component" table 的纵向尺寸并增加 "marks"、"demerit" 和 "notes" 的尺寸?
我尝试调整 layout_weight
、 layout_width
和 layout_size
但不知何故我再也看不到 table header。
横向视图
纵向视图
我想在人像中实现什么
FragmentA.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="layout.fragmentA">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:background="@color/btn_textcolor"
android:orientation="vertical">
<TextView
android:id="@+id/cur_marks"
style="@style/marks"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right"
android:text="Markah: / 18"/>
</LinearLayout>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="90dp"
android:shrinkColumns="*"
android:stretchColumns="*">
<!--Table header-->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/th_component"
style="@style/table_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Component"/>
<TextView
android:id="@+id/th_marks"
style="@style/table_header"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Marks"/>
<TextView
android:id="@+id/th_demerits"
style="@style/table_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/tableH_demerit"/>
<TextView
android:id="@+id/th_notes"
style="@style/table_header"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Notes"/>
</TableRow>
<!--Component A1-->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:id="@+id/tv_cA1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="@dimen/text_padding"
android:text="@string/cB1"/>
<TextView
android:id="@+id/tv_mA1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/_12"
android:layout_weight="1"
android:gravity="center"/>
<CheckBox
android:id="@+id/checkBox_a1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="visible"/>
<Button
android:id="@+id/btn_a1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/catatan"/>
</TableRow>
</TableLayout>
Strings.xml
<resources>
<string name="app_name">hellowWorld</string>
<string name="title_case_detail">Case Detail</string>
<string name="cB1">Kawalan suhu dan tempat mempamerkan makanan yang sesuai mengikut keadaan
dan jenis makanan: \n
- Suhu makanan panas: > 60 °C \n
- Suhu makanan dingin: 1 °C hingga 4 °C \n
- Suhu makanan sejuk beku: <= -18 °C
</string>
如果它看起来像横向视图中的那个,那将非常有帮助。
如果您将 weight_sum 赋予 TableRow 并将权重平均分配给子项,它将正常工作
Note: for child item, we should give android:layout_width="0dp"
试试这个,
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:background="#555"
android:orientation="vertical">
<TextView
android:id="@+id/cur_marks"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right"
android:text="Markah: / 18"/>
</LinearLayout>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="90dp"
android:background="#fff"
android:shrinkColumns="*"
android:stretchColumns="*">
<!--Table header-->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="5">
<TextView
android:id="@+id/th_component"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center"
android:text="Component"/>
<TextView
android:id="@+id/th_marks"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Marks"/>
<TextView
android:id="@+id/th_demerits"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="tableH_demerit"/>
<TextView
android:id="@+id/th_notes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Notes"/>
</TableRow>
<!--Component A1-->
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="5">
<TextView
android:id="@+id/tv_cA1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="@string/cB1"/>
<TextView
android:id="@+id/tv_mA1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="_12"/>
<CheckBox
android:id="@+id/checkBox_a1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:visibility="visible"/>
<Button
android:id="@+id/btn_a1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="catatan"/>
</TableRow>
</TableLayout>
如何在纵向设置 table 行宽和大小?我更喜欢它在横向视图中的外观。有没有办法让我缩小 "Component" table 的纵向尺寸并增加 "marks"、"demerit" 和 "notes" 的尺寸?
我尝试调整 layout_weight
、 layout_width
和 layout_size
但不知何故我再也看不到 table header。
横向视图
纵向视图
我想在人像中实现什么
FragmentA.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="layout.fragmentA">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:background="@color/btn_textcolor"
android:orientation="vertical">
<TextView
android:id="@+id/cur_marks"
style="@style/marks"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right"
android:text="Markah: / 18"/>
</LinearLayout>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="90dp"
android:shrinkColumns="*"
android:stretchColumns="*">
<!--Table header-->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/th_component"
style="@style/table_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Component"/>
<TextView
android:id="@+id/th_marks"
style="@style/table_header"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Marks"/>
<TextView
android:id="@+id/th_demerits"
style="@style/table_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/tableH_demerit"/>
<TextView
android:id="@+id/th_notes"
style="@style/table_header"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Notes"/>
</TableRow>
<!--Component A1-->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:id="@+id/tv_cA1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="@dimen/text_padding"
android:text="@string/cB1"/>
<TextView
android:id="@+id/tv_mA1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/_12"
android:layout_weight="1"
android:gravity="center"/>
<CheckBox
android:id="@+id/checkBox_a1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="visible"/>
<Button
android:id="@+id/btn_a1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/catatan"/>
</TableRow>
</TableLayout>
Strings.xml
<resources>
<string name="app_name">hellowWorld</string>
<string name="title_case_detail">Case Detail</string>
<string name="cB1">Kawalan suhu dan tempat mempamerkan makanan yang sesuai mengikut keadaan
dan jenis makanan: \n
- Suhu makanan panas: > 60 °C \n
- Suhu makanan dingin: 1 °C hingga 4 °C \n
- Suhu makanan sejuk beku: <= -18 °C
</string>
如果它看起来像横向视图中的那个,那将非常有帮助。
如果您将 weight_sum 赋予 TableRow 并将权重平均分配给子项,它将正常工作
Note: for child item, we should give
android:layout_width="0dp"
试试这个,
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:background="#555"
android:orientation="vertical">
<TextView
android:id="@+id/cur_marks"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right"
android:text="Markah: / 18"/>
</LinearLayout>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="90dp"
android:background="#fff"
android:shrinkColumns="*"
android:stretchColumns="*">
<!--Table header-->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="5">
<TextView
android:id="@+id/th_component"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center"
android:text="Component"/>
<TextView
android:id="@+id/th_marks"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Marks"/>
<TextView
android:id="@+id/th_demerits"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="tableH_demerit"/>
<TextView
android:id="@+id/th_notes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Notes"/>
</TableRow>
<!--Component A1-->
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="5">
<TextView
android:id="@+id/tv_cA1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="@string/cB1"/>
<TextView
android:id="@+id/tv_mA1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="_12"/>
<CheckBox
android:id="@+id/checkBox_a1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:visibility="visible"/>
<Button
android:id="@+id/btn_a1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="catatan"/>
</TableRow>
</TableLayout>