[英]TextView: Remove spacing and padding on top and bottom
我有一個大小為 50 dp 的文本視圖。 我得到了如下圖所示的結果。
我想刪除 textView 中的底部空格,因為它的高度取決於文本大小。 而且我只想在我的引號中接收背景。 有沒有辦法刪除我的 textView 中未使用的空格?
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="top"
android:text="“"
android:fontFamily="@font/arialbd"
android:background="#ff0"
android:textColor="#E8E9EF"
android:includeFontPadding="false"
android:textSize="50dp" />
嘗試這個:
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="top|center"
android:text="“"
android:fontFamily="@font/arialbd"
android:background="#ff0"
android:textColor="#E8E9EF"
android:includeFontPadding="false"
android:textSize="50dp"
android:gravity="top" />
此解決方案適用於我的情況。 去除底部填充。 將layout_height
設置為與textSize
相同的大小或小於 1dp 或 2dp。
設置includeFontPadding="false"
。 設置android:lineSpacingExtra="0dp"
在您的情況下,您必須實現自定義 textView。 檢查此示例以供參考。
您可以嘗試將底部邊距設置為負值。
像這樣的東西:
android:layout_marginBottom="-10dp"
讓我知道它是否有效,這是最簡單的方法,但可以是其他方法......
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.