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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:15:40+00:00 2026-06-11T01:15:40+00:00

I have a frame layout encompassing an imageview that’s supposed to update the image

  • 0

I have a frame layout encompassing an imageview that’s supposed to update the image it’s showing when the user presses the next button (think of a slideshow). All the images that I want to thusly put in this imageview are of the same dimensions. The initial image that’s shown by the imageview at the start of the activity is in the res/drawable-hdpi directory, while the other images live in the assets directory. The problem is that the images that I swap into the imageview appear smaller than the first image although all these images are of the same size.

With regard to layout parameters, my frame layout’s layout_width and layout_height are set to wrap_content and so is the imageview, I tried setting the scaleType parameter to every possible value and I still see the same results. So unless the images stored in res/drawable-hdpi and assets are somehow scaled differently this behavior shouldn’t happen.

So, what’s the best approach to preserve the dimensions of the imageview as the user cycles through these images?

Here is my XML for the frame layout & my imageview

<FrameLayout
  android:id="@+id/coverLayout"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_centerInParent="true" >

  <ImageView
    android:id="@+id/coverImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="false"
    android:scaleType="fitCenter"
    android:src="@drawable/coverImage" />
</FrameLayout>

Here is my code that loads new images into my imageview

_coverImageView = (ImageView) findViewById(R.id.coverImageView);
...
...
if (loadNewImage) {
        AssetManager assetMgr = getAssets();
        InputStream stream;
        try {
            stream = assetMgr.open("covers/" + _coverImageName);
            Drawable coverDrawable = Drawable.createFromStream(stream, _coverImageName);
            _coverImageView.setImageDrawable(coverDrawable);
        }
        catch (IOException ex) {                        
            System.out.println(ex);
        }
}
  • 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-11T01:15:41+00:00Added an answer on June 11, 2026 at 1:15 am

    So unless the images stored in res/drawable-hdpi and assets are somehow scaled differently this behavior shouldn’t happen.

    This is exactly the issue. Android scales bitmaps based on several rules including the density (class) of the screen and which resource folder the bitmap was from. See this related question/answer. If you want the same behavior for both assets and resources, you can put the initial cover image in drawable-nodpi instead of drawable-hdpi.

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

Sidebar

Related Questions

I have custom gallery. Gallery represents items that are frame layout. There are one
I have a CSS layout that simulates a fixed-frame page, with a header and
Right I have a main layout defined, that has a frame, a table in
I have textview and imageview in the frame layout, i want move the text
Ho I have two list view on a frame layout. I want one overlay
I have wrote a method to convert any layout Liner,Relative,Frame etc into Bitmap but
I have a view in the UI that is technically an extended ImageView inside
Suppose I have a data frame, df, that looks like: f t1 t2 t3
I have a Text View (without a Scroll view) Inside of a Frame Layout.
The layout... I have a UIToolbar that loads a view with several buttons. One

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.