2012-10-23 11 views
5

क्षमा करें अगर मैं ऐसा मूल प्रश्न पूछ रहा हूं। मैंने पूरी सुबह Google पर कोशिश करने की कोशिश की है, और डेवलपर.android.com पर दस्तावेजों के माध्यम से पढ़ा है, लेकिन मुझे कोई समाधान नहीं मिला।एंड्रॉइड जीयूआई - अगली पंक्ति में बटन को कैसे बल दें?

संक्षेप में, मैं एक अंतरफलक है कि इस तरह दिखता है बनाने के लिए करना चाहते हैं:

enter image description here

अब, मैं कर रहा हूँ:

enter image description here

यह वही है मैं अब तक किया है अगली पंक्ति में 2 बटन लाने की कोशिश कर रहा है, लेकिन मुझे अभी भी इसके साथ कोई भाग्य नहीं है। अगर मैं एंड्रॉइड बदलता हूं: अभिविन्यास = "क्षैतिज" "लंबवत" तक, सब कुछ लंबवत रूप से गठबंधन किया गया था। मैंने बटन टैग के अंदर लाइन एंड्रॉइड: अभिविन्यास = "लंबवत" लाने की कोशिश की, लेकिन ऐसा लगता है कि यह काम नहीं कर रहा था।

मैं और क्या प्रयास कर सकता हूं? क्या कोई मुझे कुछ पॉइंटर्स देगा? (मैं एंड्रॉइड विकास और इन सभी एक्सएमएल सामान में नया हूं)।

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="horizontal" 
> 

<EditText android:id="@+id/txt_Input" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:hint="@string/txt_Input" 

     android:layout_weight="4"      
/> 
<Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/btn_Send" 

     android:layout_weight="1" 

     android:onClick="sendMessage" 
/> 

<Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/btn_Send" 

     android:layout_weight="1" 

     android:onClick="sendMessage" 
/> 

</LinearLayout> 

उत्तर

4

बस RelativeLayout उपयोग करें, और अपने बटन कुछ इस तरह दिखना चाहिए: खड़ी करने के लिए

<Button 
    android:id="@+id/send" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/btn_Send" 
    android:onClick="sendMessage" 
    android:layout_below="@+id/txt_Input" 
    android:layout_alignParentLeft="true"/> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/btn_Send" 
    android:onClick="sendMessage" 
    android:layout_below="@+id/txt_Input" 
    android:layout_toRightOf="@+id/send"/> 
+0

आपके विस्तृत उत्तर के लिए धन्यवाद। वह बहुत उपयोगी था! – TATN

+0

छोटे सुधार, यह toRightOf है, नहीं toRighof –

6

के साथ क्षैतिज तो यह लाइनों के लिए क्षैतिज UI घटक के सभी सेट है उन्मुखीकरण अप आप एक LinearLayout में सभी चीज़ें हैं:


नीचे मेरी XML कोड है। आपको इसे रिलेवेटिवआउट का उपयोग करने की आवश्यकता है और बटन को संपादन टेक्स्ट के नीचे लेआउट पर सेट करें।

+2

वैकल्पिक रूप से, सेट अभिविन्यास और edittext नीचे दिए गए बटन को संलग्न करने के लिए एक नेस्टेड क्षैतिज रेखीय लेआउट का उपयोग करें। – withoutclass

+2

@withoutclass: यह केवल सापेक्ष लेआउट – Asahi

+0

से कम कुशल होगा, इसमें कोई अंतर नहीं होना चाहिए। – CaseyB