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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:13:43+00:00 2026-06-18T09:13:43+00:00

I wanted my image buttons to maintain their aspect ratio so I followed https://stackoverflow.com/a/7966838/135135

  • 0

I wanted my image buttons to maintain their aspect ratio so I followed https://stackoverflow.com/a/7966838/135135

and set the background to be null, and then set the image button source image to be the image button. The issue is now that the image button is not aligning with the parent as it was anymore. How do I make it align with the parent right edge again?

        ImageButton bt = new ImageButton(this);        
        bt.setImageResource(R.drawable.next_button);
        bt.setBackgroundDrawable(null); 

        bt.setAdjustViewBounds(true);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
        params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);


        bt.setLayoutParams(params);        
        return bt;
  • 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-18T09:13:44+00:00Added an answer on June 18, 2026 at 9:13 am

    I ended up just hard coding the dimensions in for the button in dp. I searched a bunch and could not find anyone with a good solution other than this.

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

Sidebar

Related Questions

I am new to jquery. I wanted to generated a set of image button
I wanted to put a background image partially visible behind a list view. I
I have made a image gallery with jQuery found here: http://sarfraznawaz2005.kodingen.com/demos/jquery/image_gallery/ I just wanted
I wanted to make two equally-sized radio buttons with a custom background, text, and
I wanted to use a retina resolution image (40x40p) on a bar button item
I wanted to upload a jpeg image file on the server.I have a GoAhead
Wanted to see if anyone knows how to add props to a image with
If i wanted to crop an image in VB.net, how would I go about
i just wanted to put a selection on my picturebox.image but this has just
So I wanted to have something like in this image . Basically you have

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.