Android TableLayout:在4个单元格上跨2个文本视图
Android application layout.xml包含三行。第一行和第二行(每行)由4个单元格组成,第三行由2个单元格组成(Android TableLayout:在4个单元格上跨2个文本视图,android,tablelayout,tablerow,Android,Tablelayout,Tablerow,Android application layout.xml包含三行。第一行和第二行(每行)由4个单元格组成,第三行由2个单元格组成(textview)。其目的是在整行的第3行上跨越2个文本视图。这两个textview的长度不同,因此layout_span(跨越两个单元格上的两个元素中的每一个)不会产生预期的效果。通过权重实现了一些改进,但是跨越的第3行对第1行和第2行产生了一些影响 我通过使用内部TableLayout包装第三行来解决这个问题(它代替了第三行TableRow): 但是,出现
textview
)。其目的是在整行的第3行上跨越2个文本视图。这两个textview
的长度不同,因此layout_span
(跨越两个单元格上的两个元素中的每一个)不会产生预期的效果。通过权重
实现了一些改进,但是跨越的第3行对第1行和第2行产生了一些影响
我通过使用内部TableLayout
包装第三行来解决这个问题(它代替了第三行TableRow
):
但是,出现了一些不愉快的消息:TableRow
内部的TableLayout
被认为是无用的,建议我删除其中的一个。这种行为的逻辑是明确的,但在这种情况下,需要TableLayout
及其TableRow
。所以,问题是:有没有办法在不压制的情况下避免这一信息
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/sunrizeLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:labelFor="@id/sunrizeValue"
android:text="@string/sunrize_string" />
<EditText
android:id="@+id/sunrizeValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:importantForAutofill="no"
android:inputType="time"
android:textIsSelectable="true" />
<TextView
android:id="@+id/middayLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:labelFor="@id/middayValue"
android:paddingHorizontal="5dp"
android:text="@string/midday" />
<EditText
android:id="@+id/middayValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:enabled="false"
android:importantForAutofill="no"
android:inputType="time"
android:textIsSelectable="true" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/sunsetLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:labelFor="@id/sunsetValue"
android:text="@string/sunset_string" />
<EditText
android:id="@+id/sunsetValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:importantForAutofill="no"
android:inputType="time"
android:textIsSelectable="true" />
<TextView
android:id="@+id/midnightLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:labelFor="@id/midnightValue"
android:paddingHorizontal="5dp"
android:text="@string/midnight" />
<EditText
android:id="@+id/midnightValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:enabled="false"
android:importantForAutofill="no"
android:inputType="time"
android:textIsSelectable="true" />
</TableRow>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/daylightLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:labelFor="@id/daylightValue"
android:text="@string/daylight" />
<EditText
android:id="@+id/daylightValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:importantForAutofill="no"
android:inputType="time"
android:textIsSelectable="true" />
</TableRow>
</TableLayout>
</TableLayout>