मेरे ऐप में दो ImageView
s, एक TextView
और एक Gallery
हैं और मैं अपना लेआउट नीचे दिखाना चाहता हूं।
............................................-.
<ImageView>| <TextView> |<ImageView>|
..............................................
| |
| Gallery |
| |
|............................................|
मेरे पास एक टेबल लेआउट है और ऊपर दिखाए गए अनुसार लगभग डिग्न मिल गया है, सिवाय इसके कि जब टेक्स्ट की लंबाई छोटी होती है तो स्क्रीन के दाहिने छोर पर ImageView
चलती रहती है। मैं चाहता हूं कि स्क्रीन के बाएं और दाएं छोर पर ImageView
टेक्स्ट के आकार के बावजूद तय किया जाए।
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TableRow>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageL"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:minHeight="30px"
android:minWidth="30px" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/title"
android:paddingLeft="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:layout_gravity="center"
android:minHeight="30px"
android:minWidth="30px" />
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageR"
android:paddingLeft="10px"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:minHeight="30px"
android:minWidth="30px" />
</TableRow>
</TableLayout>
<Gallery xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
3 जवाब
कुछ ऐसा। यदि आप आईएमजी के लिए स्थिर चौड़ाई और ऊंचाई बनाना चाहते हैं तो आप इसे एंड्रॉइड में सेट कर सकते हैं: लेआउट_विड्थ और एंड्रॉइड: लेआउट_हाइट
<?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"
>
<ImageView
android:id="@+id/firstImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/icon"
/>
<TextView
android:id="@+id/someText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/secondImage"
android:layout_toRightOf="@+id/firstImage"
android:text="some mega text."
android:gravity="center_horizontal"
/>
<ImageView
android:id="@+id/secondImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/icon"
/>
</RelativeLayout>
तीनों वस्तुओं के लिए समान भार का प्रयोग करें, समस्या का समाधान होना चाहिए।
android:layout_weight="1"
सभी 3 समान क्षेत्रों पर कब्जा करेंगे।
इसे अपने टेबललेआउट-टैग में जोड़ें:
android:shrinkcolumns="0,2" android:stretchColumns="1"
साथ ही, आप इसके बजाय लेआउट_विड्थ को fill_parent में बदलना चाहेंगे, क्योंकि यह मध्य कॉलम को फैलाने की अनुमति देगा।
संबंधित सवाल
नए सवाल
android
एंड्रॉइड Google का मोबाइल ऑपरेटिंग सिस्टम है, जिसका उपयोग प्रोग्रामिंग या डिजिटल डिवाइस (स्मार्टफोन, टैबलेट, ऑटोमोबाइल्स, टीवी, वियर, ग्लास, IoT) को विकसित करने के लिए किया जाता है। एंड्रॉइड से संबंधित विषयों के लिए, एंड्रॉइड-विशिष्ट टैग जैसे कि एंड्रॉइड-इरादे, एंड्रॉइड-गतिविधि, एंड्रॉइड-एडॉप्टर आदि का उपयोग करें। विकास या प्रोग्रामिंग के अलावा अन्य प्रश्नों के लिए, लेकिन एंड्रॉइड फ्रेमवर्क से संबंधित हैं, इस लिंक का उपयोग करें: https: // android.stackexchange.com।