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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:16:51+00:00 2026-05-27T02:16:51+00:00

I have a LayerDrawable, which should display 5 Bitmaps. 1 background and 4 Icons

  • 0

I have a LayerDrawable, which should display 5 Bitmaps. 1 background and 4 Icons (which can be different for every LayerDrawable) like a Grid. Unfortunately these Icons don’t have the same width than height. My Problem is to resize them, while keeping their ratio and place them inside their Position (1-4 Icons, 5 background):

==================
|      |  |      |
|   1  |  |   2  |
|------.5 .------|
|------.  .------|
|   3  |  |   4  |
|      |  |      |
==================

If I resize these Bitmaps, give them Gravity.CENTER they won’t fit anymore inside the Bounds of the Background Rectangle. If I leave Gravity.CENTER they seem to get rescaled as soon as I call layerDrawable.setLayerInset(numlayer, left, top, right, bottom).
What is the right way to do it? How can I keep their ratio while placing them correctly?
What I also couldn’t understand so far is why getIntrinsicWidth/Height from BitmapDrawable is returning something else (smaller) than getWidth/Height from original Bitmap.
What I tried:
1. Getting them from XML, putting a ‘dummy-drawable’ inside and replace it with result described above.
2. Create LayerDrawable inside my Program passing all drawables inside. It seems that setLayerInset has no affect, or I only see the Background (which was Element 0 inside my Drawable Array)
3. Extending LayerDrawable and try to keep track on anything myself without reasonable results

  • 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-27T02:16:52+00:00Added an answer on May 27, 2026 at 2:16 am

    The BitmapDrawable, dy default, fills its bounds with the given Bitmap. If you start using Gravity, the Bitmap will be position according to the given Gravity. I suppose in your case, the best choice is to create your own Drawable.

    Concerning the getIntrinsic[Height|Width] methods, they return the actual size of your underlying Bitmap which may be different if the system resized it it while loading it (an hdpi image loaded on an mdpi screen for instance).

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

Sidebar

Related Questions

I have a LayerDrawable which I construct with an array of Drawables of 5
Have just started using Visual Studio Professional's built-in unit testing features, which as I
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:
Have a photography site that I want to prevent image copying from. How can
Have created a ATL COM project through which I am inserting Menu Items to
I'm trying to display a LayerDrawable as an ImageButton image. All the layers must
Have advancements in CPU design like dynamic instruction scheduling narrowed the performance gap between
Have anyone used Redmine Documentor which lets you convert PHP to HTML to Redmine
Have the following scenario. I have a few form, which essentially have a few
Have an app that can use tts to read text messages. It can also

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.