पर एक बहुमुखी टेक्स्ट व्यू को रोकें, एक टेक्स्ट व्यू जो कई पंक्तियों तक फैली हुई है, स्वचालित रूप से अधिकतम संभव चौड़ाई फिट करने के लिए विस्तारित होती है। मैं इसे कैसे होने से रोक सकता हूं?अनावश्यक रूप से इसकी अधिकतम चौड़ाई
यहाँ एक उदाहरण लेआउट (test.xml) है
<?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>
मैं बाईं तरफ के एक मार्जिन जोड़ देते हैं तो इसे सही ढंग से TextView की चौड़ाई (सामग्री को पुन: फ़ॉर्मेट के बिना) सिकुड़ता है, लेकिन मार्जिन के आकार को टेक्स्टव्यू की सामग्री के अनुसार गणना करना होगा।
<?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>
समस्या पैडिंग के साथ नहीं है। मैं टेक्स्टव्यू को वास्तव में सामग्री को लपेटना चाहता हूं, और इसके बजाय जब यह बहु रेखा है तो यह मूल दृश्य की चौड़ाई तक फैली हुई है। –