2011-12-13 14 views
9

मुझे इस तरह का एक लेआउट चाहिए: Desired layoutएंड्रॉइड रिलेवेटिवआउट - कैसे स्थिति है?

लेकिन मेरा कोड काम नहीं करता है। मैं इस लेआउट को प्राप्त नहीं कर सकता, और मुझे नहीं पता कि मैंने अभी तक जो किया है उसके साथ क्या गलत है।

यहां मेरे पास अभी तक है - क्या layout_gravity ठीक है? या इसे RelativeLayout में सेट करने की आवश्यकता है?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent"> 

    <RelativeLayout  
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

     <TextView 
      android:id="@+id/topText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="20dip" 
      android:layout_gravity="top" /> 

     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/centerLayout" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="horizontal" 
      android:layout_below="@id/topText">  

      <ImageButton 
       android:id="@+id/lektionBackButton" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 

       android:src="@drawable/back" 
       android:layout_gravity="left"/> 
      <ImageView 
       android:id="@+id/centerImage" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:cropToPadding="true" 
       android:layout_gravity="center"/> 
      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/lektionForwardButton" 
       android:src="@drawable/forward" 
       android:layout_gravity="right"/>   
     </LinearLayout>  

     <TextView 
      android:id="@+id/bottomText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="20dip" 
      android:layout_below="@id/centerLayout" 
      android:layout_gravity="bottom" /> 
    </RelativeLayout> 
</RelativeLayout> 
+2

सही स्नैप के साथ अच्छा सवाल। –

उत्तर

15

आप गुरुत्वाकर्षण या भीतरी LinearLayout बिल्कुल इस के लिए उपयोग करने की आवश्यकता नहीं है। इसके बजाय layout_alignParentTop, layout_alignParentLeft, layout_alignParentRight, layout_alignParentBottom, layout_centerInParent और layout_centerVertical बच्चों पर उपयोग करें।

RelativeLayout tutorial के माध्यम से जाने के लिए यह उपयोगी हो सकता है।

2

केवल एक सापेक्ष लेआउट की बात आती है, तो आप अपने ग्रहण संपादक में ग्राफ़िकल लेआउट पर स्विच कर सकते हैं और विशेषताओं को खींच और सेट कर सकते हैं। बस अपने माउस के साथ सब कुछ। हालांकि यह किसी भी अन्य लेआउट के साथ संभव नहीं है। उम्मीद है की वो मदद करदे।

संबंधित मुद्दे