我有兩個TextView並排顯示。 TextView1具有不同長度的文本,而TextView2總是說「+#」。但是,當TextView1變長時,它會將TextView2推離屏幕。任何想法如何解決這一問題?這是我的佈局代碼:Long Android TextView將其他視圖從屏幕上移開
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:textSize="13sp"/>
<TextView
android:id="@+id/TextView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="13sp"/>
</RelativeLayout>
你打算讓父視圖成爲RelativeLayout還是LinearLayout?您正在指定android:orientation =「horizontal」,並且方向僅對LinearLayout有效。此外,如果你能澄清預期的行爲,這將有所幫助。 –