Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8391209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:11:59+00:00 2026-06-09T19:11:59+00:00

I have two custom RadioButtons side by side that fill the width of the

  • 0

I have two custom RadioButtons side by side that fill the width of the screen. I want to have text and an image to the right of the text, centered in the button.

drawableRight draws the image way off to the right of the button, not near the text. I can’t use drawableEnd because I don’t have Android 4.0

I’ve tried using a Spannable, but the problem with that is that the image is bigger than the text. I don’t want it aligned with the bottom or baseline of the text; I want it to be centered in the button on its own.

The best solution I’ve found is making a clickable RelativeLayout with a TextView and ImageView centered in it. This makes the button look the way I want it to, but it seems like a lot of work to do that, and to program each RelativeLayout to act like a RadioButton in a RadioGroup.

Is there an easier way, or something that I’m missing? Or should I keep my RelativeLayout idea? Here’s my xml for this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <RelativeLayout
        android:id="@+id/first_relativelayout"
        android:clickable="true"
        android:background="@drawable/radio_button"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal">
        <TextView
            android:id="@+id/first_textview"
            android:text="@string/first_radiobutton_label"
            android:textAppearance="?android:attr/textAppearanceButton"
            android:textColor="@android:color/white"
            android:layout_centerVertical="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"></TextView>
        <ImageView
            android:contentDescription="@string/image_description"
            android:id="@+id/first_imageview"
            android:layout_centerVertical="true"
            android:src="@drawable/it"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/first_textview">
        </ImageView>
    </RelativeLayout>

     <RelativeLayout
        android:id="@+id/second_relativelayout"
        android:clickable="true"
        android:background="@drawable/radio_button"
        android:layout_weight="1"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal">
        <TextView
            android:id="@+id/second_textview"
            android:text="@string/second_radiobutton_label"
            android:textAppearance="?android:attr/textAppearanceButton"
            android:textColor="@android:color/white"
            android:layout_centerVertical="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"></TextView>
        <ImageView
            android:contentDescription="@string/image_description"
            android:id="@+id/second_imageview"
            android:layout_centerVertical="true"
            android:src="@drawable/it"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/second_textview">
        </ImageView>
</RelativeLayout>
</LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:12:01+00:00Added an answer on June 9, 2026 at 7:12 pm

    I kept going with the RelativeLayout solution. It takes more work than it seems should be worth it, but it works perfectly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a radio group with two radiobuttons. each button has a custom selector.
I have two apps that use custom URL schemes to switch between each other.
If I am making a module, and want to have two custom paths: path/path/path/index.htm
I am creating a WPF custom control, a Button with an Image and Text
I have two custom dropdown lists that have the same markup. I need to
I have two custom-styled QPushButton buttons. Here is the stylesheet for the Ok button:
I have two custom objects, lets say Cat and Dog . I want to
I have two custom controls that are analogous to a node and the control
I have two custom validators that are in the same validation group. This validation
I have two custom ActionFilters on an action. In first of the actionfilters, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.