मुझे पता है कि मैं एक छोटी सी गलती कर रहा हूँ।
मैं LinearLayout का उपयोग कर रहा हूं और मैं "केंद्र" पर "आइकन-छवि" रखना चाहता हूं। मैं निम्नलिखित कोड का उपयोग कर रहा हूँ:
<LinearLayout
android:id="@+id/LinearLayout01"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/LinearLayout02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="0">
<ImageView
android:id="@+id/ImageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"
android:layout_gravity="center_vertical|center_horizontal|center">
</ImageView>
</LinearLayout>
<LinearLayout>
............
</LinearLayout>
</LinearLayout>
जैसा कि आप ऊपर देख रहे हैं, मैंने layout_gravity
भी सेट किया है।
अब मेरी समस्या है, if i set android:layout_width="wrap_context" instead of "fill_parent" in Child Linear Layout (i.e. LinearLayout02) then it works fine. but then whats should i do to set icon-image at Center while setting fill_parent
?
कृपया कोई भी अपने ज्ञान पर ध्यान केंद्रित करें और मुझे गलती का पता लगाने में मदद करें। कृपया मेरी मदद करें।
थैंक्स,
परेश
1 उत्तर
यह निर्दिष्ट करने के लिए कि इसकी सामग्री क्षैतिज रूप से केंद्रित होनी चाहिए, इसे LinearLayout02 में जोड़ें:
android:gravity="center_horizontal"
संबंधित सवाल
नए सवाल
android
एंड्रॉइड Google का मोबाइल ऑपरेटिंग सिस्टम है, जिसका उपयोग प्रोग्रामिंग या डिजिटल डिवाइस (स्मार्टफोन, टैबलेट, ऑटोमोबाइल्स, टीवी, वियर, ग्लास, IoT) को विकसित करने के लिए किया जाता है। एंड्रॉइड से संबंधित विषयों के लिए, एंड्रॉइड-विशिष्ट टैग जैसे कि एंड्रॉइड-इरादे, एंड्रॉइड-गतिविधि, एंड्रॉइड-एडॉप्टर आदि का उपयोग करें। विकास या प्रोग्रामिंग के अलावा अन्य प्रश्नों के लिए, लेकिन एंड्रॉइड फ्रेमवर्क से संबंधित हैं, इस लिंक का उपयोग करें: https: // android.stackexchange.com।