我在LinearLayout
裏面有一個TextView
,它只顯示其文本的一部分而沒有包裝到換行符並且無法理解原因。它甚至不會在某處顯示省略號。TextView不包裝成多行
的TextView
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/import_progress_text"
android:singleLine="false"
android:maxLines="4"
android:ellipsize="end"
style="@style/TxtDefault" />
我也試圖與layout_height=0
但仍沒有運氣一起layout_weight=0
。 LinearLayout
內的所有兄弟姐妹都有layout_height=wrap_content
集。
EDIT
好當一個固定的寬度被設定顯然它的工作原理,但既不與fill_parent
也不與match_parent
。這是預期的行爲?
每請求整個佈局
注意,裏面的FrameLayout是另一個看不見的一個,這是相當長的
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
style="@style/ContentBody"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/progress"
android:layout_gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/import_progress_title"
style="@style/TxtTitle" />
<TextView
android:layout_width="410dp"
android:layout_height="wrap_content"
android:text="@string/import_progress_text"
android:singleLine="false"
android:maxLines="4"
android:ellipsize="end"
style="@style/TxtDefault" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="410dp"
android:layout_height="wrap_content"
android:id="@+id/progress_bar_view"
android:progress="2"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/import_progress_start"
android:id="@+id/progress_text_view"
style="@style/TxtSecondary" />
</LinearLayout>
</FrameLayout>
請添加完整的佈局xml,謝謝 –
Textview layout_width應該是「wrap_content」 – randy