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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:02:52+00:00 2026-06-15T23:02:52+00:00

During the configuration phase of a widget, I would like to update a bitmap

  • 0

During the configuration phase of a widget, I would like to update a bitmap that is part of a layer-list. With all the restrictions of RemoteViews and Widgets, I see myself unable achieving this. Neither creating a new LayerDrawable manually nor retrieving and updating the drawable worked out. Do you have an idea?

Background: The Widget displays a Photo along with some other information. The photo should be framed and scale nicely, even if its sqare, landscape or portrait.

Layer-List:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@drawable/photo_01"></item>
    <item android:drawable="@drawable/photo_border"></item>
</layer-list>

The drawable @drawable/photo_border is a 9-patch bitmap.

The corresponding part from the layout:

<!-- ... -->
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:padding="20dp" >

    <ImageView
        android:id="@+id/photo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:adjustViewBounds="true"
        android:padding="4dp"
        android:scaleType="fitCenter"
        android:src="@drawable/framed_placeholder" />

</RelativeLayout>
<!-- ... -->

Thank You for sharing your thoughts.

  • 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-15T23:02:53+00:00Added an answer on June 15, 2026 at 11:02 pm

    While sleeping the problem over, I found, that I could probably just render the Bitmap manually and update the imageView. Here’s the code. It’s not nice, but get’s the job done.

    This probably can still be improved with better handling of density, etc.

    Bitmap bmp = BitmapFactory.decodeFile(sdCard.getAbsolutePath() + pathName);
    Bitmap cBitmap = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), Config.ARGB_8888);
    Canvas c = new Canvas(cBitmap);
    c.drawBitmap(bmp, 0, 0, null);
    NinePatchDrawable photo_border = (NinePatchDrawable) context.getResources().getDrawable(R.drawable.photo_border);
    photo_border.setBounds(0, 0, bmp.getWidth(), bmp.getHeight());
    photo_border.draw(c);
    
    views.setImageViewBitmap(id.photo, cBitmap);
    

    One thing to be aware of: When the phone boots, the widgets may receive an Update event, when the sd card is not mounted. You should either wait until it is, or skip the configuration and add an intent-filter (that’s what I did)

    <intent-filter>
        <action android:name="android.intent.action.MEDIA_MOUNTED"/>
        <data android:scheme="file"></data>
    </intent-filter>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there some restrictions of access to store configuration during installation of custom module
Using JOliver EventStore 3.0 with the Json Serialization addon, I'm invoking it during configuration
We have some configuration options for the rename detection heuristics during diff ( log
Program I'm making has a simple configuration file looking something like this. @overlays =
I have a directory in a dependency, that I want copied in src/main/webapp/mypath during
During configuration of JMS queues on JBoss 7 with HornetQ (based on standalone-full.xml configuration)
In clojure I have lines like this that define default values: (def *http-port* 8080)
I am continually getting the following error during testing: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to
I have a process that requires a rollback of all updates and inserts should
I would like to run the following basic procedure within my Maven 3.0.4 project.

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.