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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:50:57+00:00 2026-05-25T14:50:57+00:00

So I have this task to create a horizontal scrolling array of image buttons

  • 0

So I have this task to create a horizontal scrolling array of image buttons that are basically photo avatars of users. These avatars aren’t constrained by aspect ratio or size, and so I’ve been playing with ways to scale them and format them. I’ve gotten them scaling via the scaletype=”fitCenter” and using static width and height. But what I really want them to do is to butt up against one another. Currently if an image is taller than it is high, you get the kind of letterboxing but on the sides vs. the top (blank areas). I’ve tried all the different scaling values, wrapping each imagemap within a linearlayout, etc., but nothing I try seems to get rid of those (while displaying the entire image to scale). Is there any way to do this?

  • 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-25T14:50:57+00:00Added an answer on May 25, 2026 at 2:50 pm

    Just to reiterate what I think you’re doing, you have three image scenarios:

    1. Square image
    2. Landscape image (wider than tall)
    3. Portrait image (taller than wide)

    Laying out a row of fixed-size ImageViews (or ImageButtons) using FIT_CENTER works great for what you need if all the images were either square or landscape, because the scaling will always make the image stretch to the horizontal bounds of the view (the largest dimension). However, with portrait images, the scaling causes the view to be inside the bounds of your fixed-size view so that the entire image height can be visible.

    If you need to maintain the aspect ratio of the image, there really is no ScaleType to help with this because the logic would be circular (fit the view to the image, while simultaneously fitting the image to the view). The solution is to adjust the size (specifically, the width) of each ImageView to match what the image will be scaled to. Here’s a sample of a factory method you might use to generate the ImageView to fit the image you want to put inside it. You could also modify this slightly to reset parameters on an existing ImageView if you like:

    private ImageView getImageViewForThumbnail(Bitmap thumbnail) {
        float viewHeight = //Your chosen fixed view height
        float scale = ((float)thumbnail.getHeight()) / viewHeight;
        float viewWidth = thumbnail.getHeight() / scale;
    
        ImageView view = new ImageView(this);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams((int)viewWidth, (int)viewHeight);
        view.setLayoutParams(params);
        view.setScaleType(ScaleType.FIT_XY);
        view.setImageBitmap(thumbnail);
    
        return view;
    }
    

    You’re basically just calculating what the aspect width of the ImageView should be to match the fixed height you’ve chosen for all of them.

    HTH

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

Sidebar

Related Questions

I have this task that creates a service: Target Name=InstallService DependsOnTargets=CopyFiles Exec Command=sc \
I have a very complex task - create a software that imports XMl files
I have this task that needs investigation as to why the md5 value of
I have such task - to create control that union two controls (DataGrid from
I have created a custom task that is used to create SQL compact databases
I have this Task model: class Task < ActiveRecord::Base acts_as_tree :order => 'sort_order' end
I have this task for the project with 4 nested subprojects using Maven: For
I have this Maven task to generate Java classes from an XSD file using
I have this little rake task: namespace :db do namespace :test do task :reset
I have had no luck with this task so far so grateful for any

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.