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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:33:40+00:00 2026-06-01T17:33:40+00:00

I create a BitmapDrawable that I later assign to several Objects in a function

  • 0

I create a BitmapDrawable that I later assign to several Objects in a function like this (not exactly like this but its stripped down for testing purposes):

Drawable CreateBitmap(int col)
{   Bitmap b = Bitmap.createBitmap(50, 50, Config.ARGB_8888);
    Canvas c = new Canvas(b);
    c.drawColor(col);
    return new BitmapDrawable(b);
}

And this works and creates me a BitmapDrawable with the size 50 x 50 that I keep in memory. I then assign this BitmapDrawable to various buttons, checkboxes, whatever comes up and needs a certain color.

the problem I have is that the BitmapDrawables are somehow getting truncated. It appears that if I assign it to a button with the height of 80 and then a button with the height of 160, the first is filled nicely and the latter is only filled by half. It appears the BitmapDrawable gets set to the first usage of it and all subsequent assignments are restricted by it. Sometimes it happens immediately sometimes it only happens when I switch to another tab and return back to the previous one.

I thought the BitmapDrawable would remain at 50×50 in memory and the object its assigned to is either getting its own version with an apropriate size (or makes a resized copy when rendering) and not that it somehow changes the BitmapDrawable itself. I admit, I am not sure how all of this works in depth and I would appreciate any advice on what I am doing wrong and if I do have to create individual BitmapDrawables for each object I assign them to or if I can do something else.

  • 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-01T17:33:41+00:00Added an answer on June 1, 2026 at 5:33 pm

    The BitmapDrawable is a Drawable object, containing methods such as setState that are pretty specific to an instance of the object. So, no, I don’t think a BitmapDrawable can be easily shared. (You might be able to reuse them successfully, much as ListView caches the Views for list members; but asking a BitmapDrawable to live in two or more places at the same time seems like it’s asking too much of it.)

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

Sidebar

Related Questions

create table ImagenesUsuario { idImagen int primary key not null IDENTITY } This doesn't
I am trying to create an image slide show that is similar to this
Create Pex test to test a DLL and hardware controlled by that DLL? I
create table snippet( id int not null auto_increment, primary key(id), idlanguage int not null,
Create Table: CREATE TABLE `category` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255)
CREATE OR REPLACE PACKAGE packet AS TYPE tip IS RECORD(a1 INT,a2 VARCHAR2(20)); FUNCTION getrow
create table [User] ( UserId int primary key identity(1,1), FirstName nvarchar(256) not null, LastName
I'm using android 3.0 and I try to create bitmap xml that will create
create table #customer ( id int not null primary key, cust_name varchar(12), oldid int
Some of my users are reporting that the notification is not being displayed when

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.