TextView
का उपयोग GridLayout
अंदर समस्याग्रस्त है, लेकिन वहाँ दोनों एक साथ उपयोग करने के लिए एक अच्छा तरीका है।
यह उदाहरण लेआउट कैसा दिखता है:
और यह पूरा लेआउट एक्सएमएल है, महत्वपूर्ण लाइनों *** साथ चिह्नित हैं।
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="3" * this example uses 3 columns
android:orientation="horizontal" > *** use "horizontal"
<TextView * just a normal view
android:layout_column="0"
android:layout_row="0"
android:background="#666666"
android:text="A"
android:textColor="#afafaf"
android:textSize="60sp"
android:textStyle="bold" />
<TextView * this text will not be cut!
android:layout_width="0dp" *** important: set width to 0dp
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_columnSpan="2" * colspan does also work with this
android:layout_gravity="fill_horizontal|bottom" *** set to "fill*"!
android:layout_row="0"
android:text="This view has 2 columns. Lorem ipsum dolor sit amet, consetetur sadipscing elitr."
android:textColor="#666666" />
</GridLayout>
अपनी आवश्यकताओं पर निर्भर करता है, यह भी इस संयोजन से काम करेगा:
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="fill"
android:gravity="bottom"
नोट आप की जरूरत नहीं है कि किसी भी इस काम करने के लिए android
के अलावा अन्य नाम स्थान का उपयोग करें।
** ऐप को नोट करना महत्वपूर्ण है: ** layout_gravity। मैं एक शैली में मूल्य स्थापित कर रहा था और यह लिंट ने मुझे चेतावनी नहीं दी, मुझे समस्या का पता लगाने में थोड़ी देर लग गई। – basilisk
यह पिछली पंक्ति की चौड़ाई की चौड़ाई लेता है यदि यह दूसरी पंक्ति –