2012-01-25 17 views
11

मैं 4 आइटमों की एक रेडियो बटन सूची बनाने की कोशिश कर रहा हूं। प्रत्येक आइटम को इसके दाईं ओर टेक्स्ट होना चाहिए, लेकिन टेक्स्ट के दाईं ओर एक छवि भी होनी चाहिए। छवि रेडियो बटन ही नहीं है, यह विकल्प का वर्णन करने वाली एक छवि है। मेरे पास अभी तक कोई भाग्य नहीं है, डिजाइनर चीजों को जगह में रखने के लिए बेकार प्रतीत होता है। आपको यह जानना होगा कि एक्सएमएल में इसे कैसे कोड करें। मेरे एक्सएमएल इस तरह दिखता है:एक रेडियो बटन के दाईं ओर एक छवि कैसे डालें, एंड्रॉइड

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" android:weightSum="1" android:baselineAligned="true" android:orientation="horizontal"> 
    <RadioGroup android:layout_weight="0.50" android:layout_height="wrap_content" android:id="@+id/radioGroup1" android:layout_width="0dp"> 
     <RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:checked="true" android:text="A" android:id="@+id/radio0"></RadioButton> 
     <ImageView android:layout_toRightOf="@id/radio0" android:layout_height="wrap_content" android:src="@drawable/A2" android:layout_width="wrap_content" android:id="@+id/imageView1"></ImageView> 
     <RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="B" android:id="@+id/radio1"></RadioButton> 
     <RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="C" android:id="@+id/radio2"></RadioButton> 
     <RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="D" android:id="@+id/radio3"></RadioButton> 
    </RadioGroup> 

</LinearLayout> 

यहाँ मैं कोई सफलता के साथ, तो पहले रेडियो बटन के दाईं ओर एक छवि डाल करने के लिए tryiong हूँ। मैं छवियों को रेडियो बटन के दाईं ओर कैसे रखूं?

उत्तर

17

एक बटन के लिए आप ड्रॉबल्स को ऊपर/दाएं/बाएं/नीचे के नीचे डाल सकते हैं। तो मैंने सोचा कि यह रेडियोधर्टन के लिए एक ही तरह से काम कर सकता है।

Android डेवलपर साइट

आप इस कोशिश की में this link पर एक नज़र है?

अद्यतन

अपने मामले में

तो, imageView को हटा दें और अपने दृश्य में अपने radiobuttons में android:drawableRight (या बाएं/नीचे/ऊपर) जोड़ने

<RadioButton 
    android:drawableRight="@drawable/A2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:checked="true" 
    android:text="A" 
    android:id="@+id/radio0"/> 
0

उपयोग android:drawableXXXXX छवियों/drawable जोड़ने के लिए , यदि आप कुछ पैडिंग जोड़ना चाहते हैं तो ड्रॉइंग पैडिंग का उपयोग करें।

1
<RadioButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:drawableLeft="@drawable/ic_launcher"/> 

RadioButton ही डिफ़ॉल्ट के रूप में एक TextView .. शामिल है ताकि आप सभी कार्यों को उन किसी भी TextView के लिए मौजूद हैं कर सकते हैं।

बोनस: यदि आप सर्कुलर डॉट को बदलना चाहते हैं जो चेक स्थिति दिखाता है, तो बस अपने स्वयं के ड्रॉइंग को संदर्भित करने के लिए एंड्रॉइड: बटन टैग अपडेट करें।

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