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

  • SEARCH
  • Home
  • 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 8031851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:13:45+00:00 2026-06-05T01:13:45+00:00

I have a checkbox with a custom icon (bigger than the default icon) for

  • 0

I have a checkbox with a custom icon (bigger than the default icon) for the checkbox which I set like this:

mon  = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.checkbox_on));
moff = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.checkbox_off));

state = new StateListDrawable();
state.addState(new int[] {-android.R.attr.state_checked}, moff);
state.addState(new int[] { android.R.attr.state_checked}, mon);

cb.setButtonDrawable(state);

It works well on a phone but on a tablet with a larger screen and resolution the icon is much larger but the text at the same time is much smaller than on the phone and the icon overlays the first few letters of the text. How can I prevent this?

Edit:

I verified that the problem is from the custom checkbox icon having a different size than the default checkbox icon. The sizes seem to be different for both devices, so is there a maybe way to find out which size the default checkbox icon has so I can make necessary adjustments to the size of custom icons or the padding ?

  • 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-05T01:13:46+00:00Added an answer on June 5, 2026 at 1:13 am

    I solved it by scaling the checkbox icon dynamically based on the dpi. So it always fits and the text is also ok:

    int gg = (int) (this.getResources().getDisplayMetrics().density * cb_info.getCompoundPaddingLeft());
    mon  = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.checkbox_on ));
    int scalex = gg;
    int scaley = mon.getBitmap().getHeight() * gg / mon.getBitmap().getWidth ();
    
    mon  = new BitmapDrawable(Bitmap.createScaledBitmap( BitmapFactory.decodeResource(getResources(), R.drawable.checkbox_on ), scalex, scaley, true));
    moff = new BitmapDrawable(Bitmap.createScaledBitmap( BitmapFactory.decodeResource(getResources(), R.drawable.checkbox_off), scalex, scaley, true));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom checkbox node tree . The structure is like this .
I have custom CSS for checkbox control into my web form, which is linked
I currently have a custom CheckBox style which I use in a DataGrid. However,
I have a asp.net webpage that contain a custom login control like this: <div
in a ASP.net C# application I have a Checkbox with a custom css. the
I have a Custom Control that has multiple textbox fields and a checkbox contained
I'm trying to setup custom validation for a checkbox. I have 7 checkboxes each
I have a checkbox which in some cases may be disabled and checked using
I have a checkbox who's checked value is bound to a binding source which
I'm a tad confused. I have a Repeater which populates a list of Checkbox

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.