How do I reduce the line spacing between text in my Android layout?

南笙酒味 提交于 2019-12-03 04:38:51
Cullan

Long time since the question was asked but if anyone needs an answer in the future this can be achieved simply by passing a negative value to

android:lineSpacingExtra="-4dp"

Setting lineSpacingMultiplier seems better in this case than lineSpacingExtra, e.g.

android:lineSpacingMultiplier="0.8"

(This works if all your text is in a single TextView that has the above line in the xml.)

As Cullan says above, you have to put a negative margin value:

android:layout_marginTop="-10dp"

<TextView
    android:id="@+id/scoreDesc"
    android:text="User12"
    android:layout_marginLeft="5dip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textAppearance="@android:style/TextAppearance.Small"
    android:singleLine="true"
    android:ellipsize="marquee"
    android:layout_weight="1"
    android:layout_gravity="center_vertical" />
<TextView
    android:id="@+id/scoreDesc"
    android:text="5 movies"
    android:layout_marginLeft="5dip"
    android:layout_marginTop="-10dp"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textAppearance="@android:style/TextAppearance.Small"
    android:singleLine="true"
    android:ellipsize="marquee"
    android:layout_weight="1"
    android:layout_gravity="center_vertical" />

Hope this helps someone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!