删除堆叠的 TextView 之间的空间 [英] Remove space between stacked TextViews

查看:20
本文介绍了删除堆叠的 TextView 之间的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个垂直的 LinearLayout,里面有两个 TextView.前者包含一个静态文本属性(它的文本永远不会改变),最后一个包含一个回归计时器.下图显示了这两个项目:

I have a vertical LinearLayout with two TextView inside it. The former contains a static text property (it's text never change) and the last contains a regressive timer. The image below shows both items:

我想消除两个文本都有顶部和底部的空格.我尝试了几种方法...

I want to eliminate the blank space that both texts have both top and bottom. I've tried several approaches...

android:includeFontPadding="false"
android:lineSpacingMultiplier="1"
android:lineSpacingExtra="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"

...但他们都没有删除文本上方的空格.如何使两个文本彼此靠近而没有多余的空间?

...but none of them removed the space above the text. How can I make both texts close to each other without any extra space?

PS:我发现 这个类似的问题,但是没有人回答.

PS: I've found this similar question, but no one answered it.

完整的布局代码:

<LinearLayout 
    android:id="@+id/boxTime"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp" >

    <TextView
        android:id="@+id/textRemainingTime2"
        android:layout_width="wrap_content"
        android:layout_heigh="wrap_content"
        android:layout_gravity="center"
        android:gravity="center_horizontal"
        android:textSize="70sp"
        android:includeFontPadding="false"
        android:lineSpacingMultiplier="1"
        android:lineSpacingExtra="0dp"
        android:paddingTop="0dp"
        android:paddingBottom="0dp"
        android:layout_marginTop="0dp"
        android:layout_marginBottom="0dp"
        android:text="@string/title" />

    <TextView
        android:id="@+id/textRemainingTime"
        android:layout_width="wrap_content"
        android:layout_heigh="wrap_content"
        android:layout_gravity="center"
        android:gravity="center_horizontal"
        android:includeFontPadding="false"
        android:lineSpacingMultiplier="1"
        android:lineSpacingExtra="0dp"
        android:paddingTop="0dp"
        android:paddingBottom="0dp"
        android:layout_marginTop="0dp"
        android:layout_marginBottom="0dp"
        android:textSize="107sp"
        android:text="@string/timer" />

</LinearLayout>

推荐答案

尝试使用负边距.可能需要花点时间才能弄好数字,但我以前做过,而且效果很好.

Try using negative margins. It may take a bit of playing with the numbers to get it right, but I've done it before and it worked out well.

android:layout_marginTop="-5dp"

这篇关于删除堆叠的 TextView 之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆