Как уменьшить расстояние между текстами в макете Android? - программирование
Подтвердить что ты не робот

Как уменьшить расстояние между текстами в макете Android?

Я хотел бы уменьшить расстояние между текстами (User12, 5 фильмов, улучшение на 2.5%) в прикрепленном макете.

enter image description here

Здесь xml ниже (я попытался удалить оператор singleLine = "true" и попытался установить его на false):

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="?android:attr/listPreferredItemHeight"
  android:orientation="horizontal" >

  <ImageView
    android:id="@+id/icon"
    android:src="@drawable/icon"
    android:layout_width="36dip"
    android:layout_height="36dip"
    android:layout_margin="5dip"
    android:scaleType="center"
    android:layout_gravity="center_vertical" />

   <LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="7.5">
    <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_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="2.5% improved"
        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" />
  </LinearLayout>
  <TextView
    android:id="@+id/scoreNum"
    android:text="32"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:textSize="20sp"
    android:textStyle="bold"
    android:paddingLeft="10dip"
    android:paddingRight="60dip"  
    />

</LinearLayout>
4b9b3361

Ответ 1

Долгое время, когда вопрос задавался, но если кому-то нужен ответ в будущем, это может быть достигнуто просто путем передачи отрицательного значения

Android: lineSpacingExtra = "- 4ДП"

Ответ 2

Как говорит Куллан выше, вы должны указать отрицательное значение маржи:

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" />

Надеюсь, это поможет кому-то.