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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:37:52+00:00 2026-06-13T05:37:52+00:00

I am dynamically loading images to a image buttons on my screen. The images

  • 0

I am dynamically loading images to a image buttons on my screen. The images will not be known in advance and are diff size.

Does anyone know how to ensure the imagebutton size remains unaltered by whatever image is assigned to it. Preferably stretching the image to fit the button. I have tried using android:scaleType=”fitXY” and setting th ewidth and height to hard values (not preferable). No matter what i do the image dictates the size of the button not vice versa! Help!

I tried a combo of the following. the images come randomly from a search of internet.

                    <ImageButton
                        android:id="@+id/ImageButton1"
                        android:layout_height="93px"
                        android:src="@drawable/image1"
                        android:layout_width="93px"
                        android:background="93px" />
                    <ImageButton
                        android:id="@+id/ImageButton4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/image1"
                        android:scaleType="fitXY" />

Much appreciated of any help!

  • 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-13T05:37:53+00:00Added an answer on June 13, 2026 at 5:37 am

    Instead of setting the size of each ImageButton, place the button in a container layout and set the size of the container. For example:

    <LinearLayout
            android:id="@+id/container"
            android:layout_width="80dp"
            android:layout_height="80dp" >
    
            <ImageButton
                android:id="@+id/ImageButton1"
                android:src="@drawable/image1"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:scaleType="fitXY" />
    </LinearLayout>
    

    That should force your image button to be no bigger than the size of the container that it resides in.

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

Sidebar

Related Questions

I've been trying to get image-loading dynamically- size dynamically to set wrapper div height
I'm dynamically loading images from a web service. The images will be loaded (with
I am using JSF and have made a custom servlet for loading images dynamically.
I'm loading in 3 images (named 1.jpg, 2.jpg, 3jpg) dynamically to 3 divs called
I am loading images from a database and want to dynamically resize them according
I want to align images loading in a div dynamically . I have thought
I'm dynamically loading images from a different website into an asp.net ListView control like
I recently ran into a problem with dynamically (lazy) loading images within elements (UIViewController-Subclasses)
I'm trying to find an efficient algorithm for dynamically loading background-images for a bunch
Buttons are created dynamically and images are given to them through parsed urls, so

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.