每當在樣式xml表單上設置android:layout_gravity="bottom"
屬性時,文本似乎在頂部被截斷,在底部出現額外的空行。我已經設置了這個功能,以便在顯示太多文本時自動滾動到底部。這是託管在DialogFragment
。設置layout_gravity時,ScrollView/TextView不顯示所有數據
注意:正在顯示的文本是從TextView.setText(Html.fromHtml())
開始的,換行符是< br>
(如果有的話)。 a的打印只是測試數據。
在調試TextView時,它顯示數據在那裏(在mText變量中),但它只是不顯示。
對話框XML表:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true" >
<TextView android:id="@+id/status_olcr_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
</ScrollView>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarStyle" >
<Button
android:id="@+id/status_olcr_ok"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/ok"
style="?android:attr/buttonBarButtonStyle"
android:clickable="false" />
</LinearLayout>
上正在發生什麼的屏幕顯示(但不應該):
這是應該發生什麼(當時ERE沒有layout_gravity屬性):
的發生了什麼你知道嗎?
更新:我已經打開「顯示佈局利潤率」和TextView的是滾動型邊界上方呈現(或周圍其他方法)。請參見下面的圖片:
後綴xml with gravity set – Gordak
爲什麼你要設置'gravit沒有設置'weight_sum'爲父。 –
@Gordak不知道你的意思對不起,重力是標題'下設<:ID =「@ + ID/status_olcr_text」機器人:機器人的TextView = layout_gravity「底部」>' – marco9999