我有一個RelativeLayout,其中我將一個TextView放置在一個按鈕的左側,該按鈕被分配了父權。所以,當在TextView中顯示的文本比wrap_Content增加的多時,它會在Button上重疊。所以,我需要一個解決方案來在下一行顯示超出的文本。 任何人都可以幫助我解決這個問題?
在下面的佈局中,如果TextView2的文本是「11111111111111111111111」,它將與TextView1重疊。如何防止呢?
我的佈局如下: 如何動態調整Android TextView的寬度
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:scaleType="fitXY"
android:src="@drawable/icon" >
</ImageView>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageView1"
android:layout_margin="5dp"
android:text="TextView"
android:textSize="22dp"
android:layout_toRightOf="@id/imageView1"
>
</TextView>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:focusable="false"
android:text="Button"
android:layout_alignTop="@+id/imageView1"
>
</Button>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/button1"
android:text="TextView222"
android:textSize="22dp"
android:layout_margin="5dp"
android:layout_alignTop="@+id/imageView1"
android:ellipsize="end"
>
</TextView>
在上面的佈局,如果TextView2的文字是 「11111111111111111111111」 將與TextView1重疊。如何防止
在頂部添加了我的佈局。 – user1276092
在上面的佈局中,如果TextView2的文本是「11111111111111111111111」,它將與TextView1重疊。如何防止呢? – user1276092
同樣的方法。添加'layout_toLeftOf'和'layout_toRightOf'以防止一個TextView寫在另一個之上。 – Sam