मेरे पास एक सापेक्ष लयआउट है जिसमें साइड-बाय-साइड बटन की एक जोड़ी है, जिसे मैं लेआउट के भीतर केंद्रित करना चाहता हूं। मैं बटन को लाइनरलायआउट और केंद्र में रख सकता हूं कि रिलेवेटिवआउट में, लेकिन मैं अपने एक्सएमएल को यथासंभव स्वच्छ रखना चाहता हूं।रिलेवेटिवआउट में एक कंटेनर में रखे बिना कई आइटम केंद्र?
यहाँ मैं क्या करने की कोशिश की है, यह सिर्फ केंद्र में "लागू करें" बटन डालता है और "पूर्ववत करें" यह के बाईं ओर बटन:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15sp">
<TextView
android:id="@+id/instructions"
android:text="@string/instructions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="15sp"
android:layout_centerHorizontal="true"
/>
<Button
android:id="@+id/apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/apply"
android:textSize="20sp"
android:layout_below="@id/instructions"
/>
<Button
android:id="@+id/undo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/undo"
android:textSize="20sp"
android:layout_toLeftOf="@id/apply"
android:layout_below="@id/instructions"
/>
</RelativeLayout>
क्या आप उदाहरण लेआउट दे सकते हैं? मैं नहीं देखता कि यह कैसे काम कर सकता है क्योंकि आपको दूसरे के बाईं ओर एक बटन और दूसरी तरफ एक बटन रखना है, जो एक गोलाकार निर्भरता है। जो एक रिलेवेटिवआउट में एक IllegalStateException फेंकता है। –
खुद का परीक्षण किया गया ... बस प्रश्न में कोड का उपयोग करें और मैंने कहा जैसे लाइन जोड़ें ... – BrainCrash
ओह, मैं देखता हूं, मैंने "रिलेवेटिवआउट में केंद्र" को लंबवत और क्षैतिज दोनों के रूप में मिसिनरेट किया - जैसा कि टेक्स्टव्यू के नीचे केंद्र क्षैतिज के विपरीत है। यह तब समझ में आता है। –