तो मुझे ListView
में दो TextViews
प्रति पंक्ति मिली है। एक छोड़ा जाना चाहिए और दूसरा अधिकार गठबंधन किया जाना चाहिए। TextViews
दोनों में पृष्ठभूमि के रूप में एक गोलाकार आयताकार है जो केवल पाठ को अंदर लपेटना चाहिए। तो मैं इस के साथ आया था:दो टेक्स्टव्यू को संरेखित करें, पृष्ठभूमि को खींचने के बिना सूची दृश्य पर एक अन्य दाईं ओर छोड़ दिया गया है
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/text_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@drawable/bubble_purple"
android:gravity="center" >
</TextView>
<TextView
android:id="@+id/text_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@id/text_right"
android:background="@drawable/bubble_blue"
android:gravity="center" >
</TextView>
</RelativeLayout>
यह लंबे समय से ग्रंथों के लिए अच्छा लग रहा है लेकिन छोटे संदेशों के लिए नहीं:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/text_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:background="@drawable/bubble_blue"
android:gravity="center" >
</TextView>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView
android:id="@+id/text_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:background="@drawable/bubble_purple"
android:gravity="center">
</TextView>
</LinearLayout>
:
मैं भी इस तरह एक LinearLayout की कोशिश की यह छोटे संदेशों के लिए काम करता है लेकिन लंबे समय तक नहीं:
क्या TextViews
की संयुक्त चौड़ाई को मापने और इन लेआउट के बीच प्रोग्रामेटिक रूप से स्विच करने के लिए किसी भी तरह से संभव है, या क्या मैं यहां कुछ गलत कर रहा हूं?
कुछ लेआउट वजन –
कोशिश एंड्रॉयड रखो: दोनों – Android2390
के लिए layout_weight = "1" कैसे दो 'खिंचाव TextViews' चाहिए अगर पहले एक छोटा है और दूसरा बड़ा है? – Luksprog