如果第3栏的文字较大,则第2栏消失。如果设置,第2列也会消失android:stretchColumns="2,3"
。我想将minWidth
s设置为第2列。但是此属性被忽略。
现在我能帮助自己通过设置android:stretchColumns="3"
和android:shrinkColumns="3"
和应用maxWidth
上的位置2.这几乎是做这项工作的TextView的,但minWidth将更多的解决方案。
<TableLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:shrinkColumns="2,3"
android:stretchColumns="3" >
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/TextViewIdLabel"
style="@style/overlay_content"
android:text="@string/id_label"
android:textStyle="bold" />
<TextView
android:id="@+id/TextViewIdValue"
style="@style/overlay_content"
android:layout_marginLeft="4dp" />
<TextView
android:id="@+id/TextViewPersonIdLabel"
style="@style/overlay_content"
android:layout_marginLeft="8dp"
android:text="@string/person_id_label"
android:textStyle="bold" />
<TextView
android:id="@+id/TextViewPersonIdValue"
style="@style/overlay_content"
android:layout_marginLeft="4dp" />
</TableRow>
<!-- I skipped the other rows -->
</TableLayout>
如果您想知道,这是使用的样式:
<style name="overlay_content">
<item name="android:textColor">@color/foreground_color_on_dark_background</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">20sp</item>
<item name="android:ellipsize">marquee</item>
<item name="android:singleLine">true</item>
</style>
更新:
随着答案的到来,我发现了关于我的要求的更多信息,我在此注释中总结了该问题:如何将TableLayout列缩小到minWidth?
似乎这可能是您需要的实际解决方法,因此请提出我的评论。也许这可以改善,但实际上很难设置这些权重以适合您的应用程序
如何设置每列的权重而不是android:shrinkColumns
和android:stretchColumns
。因此,对于第1列,您可以将权重设置为0.2,将第2列的权重设置为0.3,将第3列的权重设置为0.5,依此类推
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句