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

  • Home
  • SEARCH
  • 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 8480439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:17:43+00:00 2026-06-10T19:17:43+00:00

The Situation: I have a imageview with a layer list of two drwables. The

  • 0

The Situation:

I have a imageview with a layer list of two drwables.
The frame drwable is 800x400px and the cover drawable is 800x380px.
Both images reside in the folder drawable

<ImageView
    android:id="@+id/preview_img_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="0.9"
    android:adjustViewBounds="true"
    android:src="@drawable/result_preview"/>

The Drwable layer list in drawable/result_preview

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:id="@+id/cover">
    <bitmap
        android:gravity="left|top"
        android:src="@drawable/cover" />
</item>
<item
    android:id="@+id/frame">
    <bitmap
        android:gravity="left|top"
        android:src="@drawable/frame" />
</item>
</layer-list>

This setup works as expected the cover is displayed framed on all devices. Now the user can replace the sample cover with another cover of the same size.

Replacing the cover in the layer list and leave the frame as is.

LayerDrawable layer = (LayerDrawable) getResources().getDrawable(R.drawable.result_preview);

InputStream coverIs = getContentResolver().openInputStream(Uri.parse(coverUri));
this.drwCover = (BitmapDrawable) BitmapDrawable.createFromStream(coverIs, coverUri);
drwCover.setGravity(Gravity.LEFT | Gravity.TOP);
//drwCover.getBitmap().setDensity(160);
layer.setDrawableByLayerId(R.id.cover, drwCover);
    imageView.setImageDrawable(layer);

The Problem:

Replacing the current cover with a new one (same dimensions as old) produces different results depending on the Device used.

On a device with a 3.2 screen and a 480×320 resolution the cover replaced fits in the frame. On a device with a 3.7 and a 800×480 resolution the replaced cover is displayed smaller then the old one.

What I found out is that the drwable in the imageview on the small device has a intrinsic height of 800×400 same as the dimensions of the drawable.
On the bigger screen the intrinsic height of the drawable is 30% bigger.

I know the the intrinsic values may differ from screen to screen.

What I was expecting is that the drawable that replaces the old one should will be scaled up the same way the old one was to +30%. But this did not happen.

Question:

Is there a option to tell the imageview or the layer list to Adpt itself? I think there should be a way to do so because the system did it already at the beginning.

  • 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-10T19:17:44+00:00Added an answer on June 10, 2026 at 7:17 pm

    For other having the same problem. 9patch png is a solution to a problem I don’t have.

    So far the only thing that came close to solve the problem was to put my resources into the folder drawable-nodpi. Here is the reference to the docs

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

Sidebar

Related Questions

Situation: I have two fixed-height divs, overflow set to hidden on both, and dynamic
I have following situation: I have a custom ListView with ImageView and TextView in
Kindda weird situation... I have an ImageView which has a click interaction associated with
Situation: I have two tables, say 'master' and 'detail', where 'master' has two columns
Situation: I have an ArrayList<String> containing a bunch of links to images (http:/www.foo.com/bar/image1.jpg, http:/www.foo.com/bar/image2.png,...
Situation I have two .NET solutions ( Foo and Bar ) and a common
I have following situation - Have a MongoService class, which reads host, port, database
Pseudo-situation: have a class (let's say BackgroundMagic ), and it has Start() and Stop()
Situation: I have an index page which loads pages into it with ajax as
Situation: I have some persons with certain skills and they can/might belong to more

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.