Birden çok satıra kadar genişleyen bir TextView, olası en yüksek genişliğe sığacak şekilde otomatik olarak genişler. Bunun olmasını nasıl engelleyebilirim?Çok satırlı bir TextView'ın gereksiz genişlikten maksimum genişliğe çıkmasını önleyin
Bu örnek bir düzeni (test.xml) olan
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<TextView
android:background="@color/green"
android:layout_alignParentRight="true"
android:id="@+id/foo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="This is the message a much shorter message"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/black" />
</RelativeLayout>
Solda bir marj eklemek, doğru (içeriğinin yeniden olmadan) TextView genişliğini küçülür, Ancak, TextView'ın içeriği dikkate alındığında marjın büyüklüğü hesaplanmalıdır.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<TextView
android:layout_marginLeft="32dp"
android:background="@color/green"
android:layout_alignParentRight="true"
android:id="@+id/foo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="This is the message a much shorter message"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/black" />
</RelativeLayout>
Sorun sorun değil. TextView'ın içeriği gerçekten sarmasını istiyorum ve bunun yerine çoklu çizgi olduğunda ana görünümün genişliğine genişler. –