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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:22:32+00:00 2026-06-11T11:22:32+00:00

I am trying to render a canvas drawn bitmap onto an ImageView in an

  • 0

I am trying to render a canvas drawn bitmap onto an ImageView in an App Widget. Unable to get that working, I am trying a simpler example, without the RemoteViews object, so just trying to render some rectangles into a canvas, and then set that on the ImageView. I just see a blank activity. Here is the code sample:

LinearLayout layout = new LinearLayout (this);
layout.setDrawingCacheEnabled(true);
try
{
    Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); 
    Canvas canvas = new Canvas(bitmap);
    Paint red = new Paint ();
    red.setColor(0xCC0000);
    Paint blue = new Paint ();
    blue.setColor (0x0099CC);
    canvas.drawRect(0, 0, 100, 100, red);
    int percent = 55;
    canvas.drawRect(0, 0, percent, 100, blue);
    ImageView imageView = new ImageView (this);
    imageView.setDrawingCacheEnabled(true);
    imageView.setImageBitmap(bitmap);
    imageView.setAdjustViewBounds(true);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
              LayoutParams.WRAP_CONTENT));
    layout.addView(imageView);

}
catch(Exception e)
{
    Log.e("ElectionForecastWidgetProvider", "error with bar", e);
}
this.setContentView(layout);

I’ve been tweaking various parts, such as trying out the setDrawingCacheEnabled method, after searching on stack overlow and in other places. Can anyone offer any insight here? Thanks!

  • 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-11T11:22:34+00:00Added an answer on June 11, 2026 at 11:22 am

    Colors are presented in ARGB format, try changing them to;

    ...
    red.setColor(0xFFCC0000);
    ...
    blue.setColor (0xFF0099CC);
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to get Java monkey engine-3 to render to a canvas/panel object
I have a chart (in bitmap format) that I'm trying to render to a
I've been trying to render the entire canvas in an IWebBrowser2 control to a
In trying to render a form im getting: NameError in Deals#new Showing /Users/nelsonkeating/Desktop/ReminDeal1/app/views/deals/_form.html.erb where
Im trying to render emails on my site. The problem is that these emails
I'm trying to implement a Scribd viewer in a Facebook app's canvas and let
Trying to render a list, each of which has an ajax form to get
When trying to render a Django template file in Google App Engine from google.appengine.ext.webapp
I'm trying to implement a function that takes a System.Drawing.Bitmap object and renders it
I'm currently trying to persist a canvas to a bitmap, and I've run into

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.