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 3423660
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:22:54+00:00 2026-05-18T06:22:54+00:00

I have these radio buttons and they need android:width=X and android:heightX however, I do

  • 0

I have these radio buttons and they need android:width="X" and android:height"X" however, I do not know how to set these properties so that they adapt to a different screen size.

Here is the code I’m using for my buttons:

    <RadioGroup android:layout_width="fill_parent"
        android:layout_height="50px" android:orientation="horizontal"
        android:checkedButton="@+id/first" android:id="@+id/states">

                <RadioButton android:id="@+id/first"
                    android:background="@drawable/button_radio" android:width="50px"
                    android:height="50px" />

                <RadioButton android:id="@+id/second"
                    android:background="@drawable/button_radio" android:width="50px"
                    android:height="50px" />

                <RadioButton android:id="@+id/third"
                    android:background="@drawable/button_radio" android:width="50px"
                    android:height="50px" />

                <RadioButton android:id="@+id/fourth"
                    android:background="@drawable/button_radio" android:width="50px"
                    android:height="50px" />

                <RadioButton android:id="@+id/fifth"
                    android:background="@drawable/button_radio" android:width="50px"
                    android:height="50px" />

    </RadioGroup>

I have tried putting the Radio buttons in a table row, but then they don’t operate properly. When I click one, it selected it, but didn’t unselect it when I clicked another.

I have tried replacing the android:width with android:layout_width but then they don’t show.

I have also tried using dip, but then the buttons didn’t show up.

I should also add that I am using drawables instead of the stock radio buttons. I don’t know if this would make a difference, but the drawables are all the same size (50px x 50px).

Does anyone know how I can set the height and width of these so they will adjust themselves to different screen sizes?

  • 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-05-18T06:22:54+00:00Added an answer on May 18, 2026 at 6:22 am

    Set the height and width using dp instead of px. See the answer to this post for more information on the units. What is the difference between "px", "dp", "dip" and "sp" on Android?

    I would also suggest you familiarize yourself with android’s documentation on supporting multiple screens.

    Okay, so I’ve taken a moment to whip up a quick example targeted at Android 1.5.

    You can find the source here.

    In short, you need to take the following steps:

    Place your images in res/drawable. You should have at least 4 icons: Pressed & Unchecked, Pressed & Checked, Not Pressed & Unchecked, Not Pressed & Checked

    Create a selector type layout in res/drawable. Here is mine:

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
      <item android:state_checked="true" android:state_pressed="false"
         android:drawable="@drawable/radio_on"/>
      <item android:state_checked="false" android:state_pressed="false"
         android:drawable="@drawable/radio_off"/>
      <item android:state_checked="true" android:state_pressed="true"
         android:drawable="@drawable/radio_on_pressed"/>
      <item android:state_checked="false" android:state_pressed="true"
         android:drawable="@drawable/radio_off_pressed"/>
    </selector>
    

    Then set-up your RadioGroup like so:

    <RadioGroup android:layout_width="fill_parent"
       android:layout_height="50dp"
       android:orientation="horizontal"
       android:checkedButton="@+id/first">
       <RadioButton android:id="@+id/first"
          android:width="50dp"
          android:height="50dp"
          android:button="@drawable/button_radio"/>
       <RadioButton android:id="@+id/second"
          android:width="50dp"
          android:height="50dp"
          android:button="@drawable/button_radio"/>
       <RadioButton android:id="@+id/third"
          android:width="50dp"
          android:height="50dp"
          android:button="@drawable/button_radio"/>
       <RadioButton android:id="@+id/fourth"
          android:width="50dp"
          android:height="50dp"
          android:button="@drawable/button_radio"/>
    </RadioGroup>
    

    I have specified dimension of 50dp as the dimension of my drawables are 50px x 50px. Also notice I am setting android:button and not android:background.

    Here is a signed APK of the project above: Custom RadioButton (Note: it is targeted to SDK version 4 so it wouldn’t request SD and Phone permissions)

    This should give the following result:
    Image of Custom RadioButton

    Hope this helps.

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

Sidebar

Related Questions

I have a group of radio buttons that I'm trying to validate with a
I have an AjaxControlToolkit.AutoCompleteExtender control attached to a textbox, and three radio buttons. When
I have this example which works great. The buttons are disabled as default and
For many of the pages in my site, i need to display the records
I have a simple core-data entity that has a Boolean attribute called subscribedToNewsletter .
I have a form that needs to allow people to search for hikes, hiking
I've got this validation script for my form (a survey). It loops through all
I want to handle html elements differently based on their type. Using jquery, how
So i am running into a perplexing (programmer caused) bug, me being the programmer.
Some background I'm displaying forms in my application and I enclose each field (or

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.