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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:58:24+00:00 2026-05-30T12:58:24+00:00

There is no setBackground() method in the RemoteViews class, so I’ve used the following

  • 0

There is no setBackground() method in the RemoteViews class, so I’ve used the following workaround:

  1. Created a FrameLayout for my app widget with an ImageView as the background view.
  2. Changed the ImageView image using setImageViewResource() method.

Unfortunately, when it comes to 9-patch drawables this method does not work. Also when an ImageView‘s android:src attribute points to 9-patch – it doesn’t work too. Is there any way to change the AppWidget‘s background image programatically using a 9-patch drawable? Thanks in advance.

EDIT
Settings the 9-patch as initial background in the XML:

<ImageView
    android:id="@+id/small_widget_layout_bg"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background_lime" />

When I use android:src="@drawable/background_lime" it doesn’t stretch the image properly, this code works fine. And the code to change the background from the AppWidgetProvider onUpdate method:

views.setImageViewResource(R.id.small_widget_layout_bg,
                    R.drawable.backgroung_lime);

This does not stretch the image as a 9-patch.

  • 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-30T12:58:25+00:00Added an answer on May 30, 2026 at 12:58 pm

    This answer was diagnosed in the above comments…

    RemoteView doesn’t allow access to View.setBackground(), so your workaround of using the android:src property of an ImageView is good, providing that the android:scaleType property is set to fitXY.

    ImageView won’t stretch it’s foreground image unless you tell it to.

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

Sidebar

Related Questions

There is a common method when using JTable TableCellRenderers for setting the background and
There are a few ways to get class-like behavior in javascript, the most common
There are numerous Agile software development methods. Which ones have you used in practice
When I set repeating background image to a UITableView by using the following code
In a sub-class of JComponent I am overriding paintComponent method to draw. The first
I'm developing a simple iOS app where there is a table view with some
Is there a way to specify an alternative background image/color for a Button in
There is a conversion process that is needed when migrating Visual Studio 2005 web
There are two weird operators in C#: the true operator the false operator If
There are two popular closure styles in javascript. The first I call anonymous constructor

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.