【发布时间】:2017-03-06 23:25:13
【问题描述】:
我有一个ListView:
<ListView
android:id="@+id/log_output"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:scrollbars="vertical"
android:stackFromBottom="true"
android:divider="@null"
android:dividerHeight="0dp"
android:transcriptMode="alwaysScroll"/>
使用自定义ArrayAdapter,使用以下布局:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/log_line_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:typeface="monospace"
android:textSize="10sp"
android:gravity="center_vertical"/>
如您所见,我已尽力禁用列表视图中的分隔符。但是,我仍然看到项目之间(垂直)可能有 1-2 像素的额外像素。如果可能的话,我想消除这个神秘的额外间距,因为它使文本在一定程度上看起来是双倍行距的。我怎样才能摆脱多余的间距?
编辑:
列表视图的屏幕截图。请注意,自动换行后的间距要细得多(大约 1-2 行像素)。列表中的每个新项目都以-- 开头。请注意,添加到列表中的新项目的间距稍大。理想情况下,我希望自动换行中使用的间距与列表项之间的间距相同。
【问题讨论】:
-
能否添加截图让我们看到多余的空间?
-
@drawinfinity:已添加屏幕截图。