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

The Archive Base Latest Questions

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

I have a gallery feeded by custom adapter using custom views as elements. I

  • 0

I have a gallery feeded by custom adapter using custom views as elements. I need these elements to be scaled by 70% by default. The problem is that gallery behaves like they are at 100% size with 30% transparent padding = spacing between elements are just big. For better understanding I attached two images with elements scaled to 100% and 70%.

Elements scaled to 100%

Elements scaled to 70%

I cannot hardcode the setSpacing as this would behave weird on different resolutions. I tried setSpacing(0) with no luck. How can I achieve that gallery would behave like the elements are small (70%) and not the original size?

I’m scaling the elements by adding setScaleX/Y to the constructor of custom element MagazineCell which extends RelativeLayout:

public MagazineCell(Context context) {
    super(context);

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    layout = (RelativeLayout) inflater.inflate(R.layout.mag_big, null);
    addView(layout);

    this.setScaleX(0.7f);
    this.setScaleY(0.7f);
}

I also tried to set the scale in drawChild() of the gallery with no luck. In adapter I’m simply using this class for gallery elements:

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    MagazineCell cell;
    position = getPosition(position);

    if (null == convertView || convertView.getClass() != MagazineCell.class) {
        cell = new MagazineCell(context);
    } else {
        cell = (MagazineCell) convertView;
    }

    return cell;
}

Gallery has no special code. I’m using SDK 11 on Acer Iconia TAB A500 running Android 3.1.

Thanks for any hints or comments.

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

    Looks like there’s no way to “trick” Gallery to measure scaled cells with their scaled width. So I just used negative spacing – setSpacing(-100); There may be a way via overriding onMeasure method on MagazineCell class and calculate scaled width. But I didn’t try this.

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

Sidebar

Related Questions

Here is what I want. I want to have a gallery of custom views
I have a gallery of products that is dynamically created using php and mysql
I have a Gallery control that displays a ListView as its adapter view. my
I have photo gallery code that does image re-sizing and thumbnail creation. I use
I my working on the site that will have image gallery. Designer idea was
I have an image gallery that I created by reading the contents inside a
I have a photo gallery I would like that every time a user does
I have a problem as the topic name says: Lets say i have gallery
I have a gallery type of interface that I'm trying to get to work,
I have a gallery that shows the images of some playing cards. Each card

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.