TextView занимает дополнительное место

Один из моих TextView - taking extra space, хотя к нему не прикреплены какие-либо отступы или поля. Как вы видите на картинке ниже

TextView занимает дополнительное место

XML-код TextView

<TextView
    android:id = "@+id/txt_bundle_change_percentage"
    android:layout_width = "wrap_content"
    android:layout_height = "wrap_content"
    android:layout_gravity = "center_vertical"
    android:alpha = "0.6"
    android:fontFamily = "@font/suisse_intl_semi_bold"
    android:text = "14.92%"
    android:textColor = "@color/bundleScreenTextColor"
    android:textSize = "@dimen/_12ssp" />    

XML-файл макета, который содержит TextView

<LinearLayout
    android:id = "@+id/bundle_change_percentage_layout"
    android:layout_width = "match_parent"
    android:layout_height = "wrap_content"
    android:layout_weight = "1"
    android:gravity = "end"
    android:orientation = "vertical">

    <LinearLayout
        android:id = "@+id/bundle_change_percentage_value_layout"
        android:layout_width = "wrap_content"
        android:layout_height = "wrap_content"
        android:orientation = "horizontal">

        <ImageView
            android:id = "@+id/txt_bundle_change_percentage_icon_up"
            android:layout_width = "@dimen/_9sdp"
            android:layout_height = "@dimen/_8sdp"
            android:layout_gravity = "center_vertical"
            android:alpha = "0.6"
            android:src = "@drawable/ic_value_up"
            android:tint = "@color/bundleScreenTextColor"
            android:visibility = "visible" />

        <ImageView
            android:id = "@+id/txt_bundle_change_percentage_icon_down"
            android:layout_width = "@dimen/_9sdp"
            android:layout_height = "@dimen/_8sdp"
            android:layout_gravity = "center_vertical"
            android:alpha = "0.6"
            android:scaleY = "-1"
            android:src = "@drawable/ic_value_up"
            android:tint = "@color/bundleScreenTextColor"
            android:visibility = "visible" />

        <TextView
            android:id = "@+id/txt_bundle_change_percentage"
            android:layout_width = "wrap_content"
            android:layout_height = "wrap_content"
            android:layout_gravity = "center_vertical"
            android:alpha = "0.6"
            android:fontFamily = "@font/suisse_intl_semi_bold"
            android:text = "14.92%"
            android:textColor = "@color/bundleScreenTextColor"
            android:textSize = "@dimen/_12ssp" />

    </LinearLayout>

    <TextView
        android:id = "@+id/txt_bundle_change_percentage_heading"
        android:layout_width = "wrap_content"
        android:layout_height = "wrap_content"
        android:alpha = "0.6"
        android:fontFamily = "@font/suisse_intl_regular"
        android:text = "@string/txt_24h_price_change"
        android:textColor = "@color/bundleScreenTextColor"
        android:textSize = "@dimen/_9ssp" />
</LinearLayout>   

ваш шрифт может быть проблемой. Попробуйте использовать шрифт по умолчанию

Vivek Mishra 27.10.2018 11:12

просто используйте android: padding = "0dp", чтобы удалить отступы по умолчанию в текстовом представлении

Sarath Kumar 27.10.2018 12:31
1
2
219
3
Перейти к ответу Данный вопрос помечен как решенный

Ответы 3

Ответ принят как подходящий
setIncludeFontPadding (boolean includepad)

или в XML это будет:

android:includeFontPadding = "false"

Благодарность! это сработало, но все еще есть место. Можете ли вы придумать еще какое-нибудь решение?

Zohab Ali 27.10.2018 11:23

Вы использовали собственный шрифт?

Solaiman Hossain 27.10.2018 11:37

когда вам нужно ближе, добавьте это, чтобы выровнять текст по верхнему краю

   textView.setGravity(Gravity.TOP);

Пожалуйста, обновите этот код. это будет работать.

<TextView
android:id = "@+id/txt_bundle_change_percentage"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:height = "24dp"
android:alpha = "0.6"
android:text = "14.92%"
android:textColor = "@color/colorAccent"
android:textSize = "24sp"
android:background = "@color/colorPrimary"
android:includeFontPadding = "false"
android:layout_marginTop = "-5dp"
android:layout_marginLeft = "-2dp"
/>

Другие вопросы по теме