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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:12:41+00:00 2026-05-24T22:12:41+00:00

I have some ImageViews inside a ViewFlipper. I want to respect the aspect ratio

  • 0

I have some ImageViews inside a ViewFlipper. I want to respect the aspect ratio of the images, so the layout won’t use all the screen. I have set up a simple “slide” animation, but the ViewFlipper will always be a bit bigger than the images inside. This makes an undesired black space appear between two sliding images. I can’t make the ViewFlipper wrap around the ImageViews correctly.

Everything is inside a FrameLayout, so there I can have a floating button there too. This is the main layout XML:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:scaleType="centerInside"
    > 
 <ViewFlipper
     android:id="@+id/flipper"
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"
     android:layout_gravity="center"   
     android:scaleType="centerInside"
     >
  <ImageView 
      android:id="@+id/page1"   
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"
      android:scaleType="centerInside"
      android:src="@drawable/bg0"
      />
  <ImageView 
      android:id="@+id/page2"   
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"
      android:scaleType="centerInside"
      android:src="@drawable/bg1"
      />   
 </ViewFlipper>
 <ImageButton
  android:id="@+id/menuButton"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="bottom"
  android:src="@drawable/btn_menu"
  android:background="@null"
  />    
</FrameLayout>

If I set the scaleType of the ImageViews to “fitXY” the black margin disappears, but the ratio of the images is not respected. I have already tried “fitCenter”, “fillParent” in the ImageViews, and a padding of 0px.

Any help is very much appreciated as I have been struggling with this for hours.

  • 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-24T22:12:42+00:00Added an answer on May 24, 2026 at 10:12 pm

    Adding this to the ImageView did it:

    android:adjustViewBounds="true"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help creating a listview inside a layout i have. im having
I have a ImageView and draw some things on that view. Now I want
I have some arbitrary pixel data that I want to save as a PNG.
I have AlertDialog with single choice list. I want to put some 'fake' items
I have some sort of image-slider to show some promotions images ('promo's). I used
I have a Layout which as a ImageView, ListView, some TextViews etc wrapped in
I currently have an image mask I want to use to mask a UIScrollView.
I'm looking for some advice on how to do this. I want to have
User can select some images to the screen, and be able to select/drag/move/zoom/rotate each
I see some questions about ImageViews, but I need a FrameLayout . I 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.