如何减少边距?

3

我的一个视图现在看起来像这样。在大的5旁边,特别是在它上面和下面,有相当大的空白。我该如何减少或移除这个空白?

输入图像描述

相关的XML代码如下:

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
    <TextView style="@style/medText" android:id="@+id/whenSee" android:text="@string/whenSee" android:layout_alignParentLeft="true" android:layout_above="@+id/newViewValue" android:gravity="center" android:layout_alignRight="@+id/button_to_press"></TextView>
    <TextView style="@style/numberSelect" android:id="@+id/newViewValue" android:text="9" android:layout_above="@+id/press_text" android:layout_alignParentLeft="true"  android:gravity="center" android:layout_alignRight="@+id/button_to_press"></TextView>
    <TextView style="@style/medText" android:id="@+id/press_text" android:layout_above="@+id/button_to_press" android:layout_alignParentLeft="true" android:text="@string/press"  android:gravity="center" android:layout_alignRight="@+id/button_to_press"></TextView>
</RelativeLayout>

样式在这里:

<style name="medText">
    <item name="android:textSize">22sp</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_width">wrap_content</item>
</style>
<style name="numberSelect">
    <item name="android:textSize">80sp</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_width">wrap_content</item>
</style>
2个回答

5
将属性android:includeFontPadding="false"添加到大型TextView中,它会收缩填充。

3
我曾经遇到过类似的问题 - 两行文字上下间距太大了。这是因为在文本中留有空间,以防重音字符粘在上一行的符号(如“y”)上。 解决方法是使用负边距:-5px,-5dp。只需在具有最多空格的TextView上将其设置为5即可。一侧安全,因为只有数字。另一方面,您永远无法知道使用的字体。 您也可以使用图像。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接