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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:48:30+00:00 2026-06-01T20:48:30+00:00

when I set the background of my editText with setBackgroundResource, everything works fine. When

  • 0

when I set the background of my editText with “setBackgroundResource”, everything works fine. When I use “setBackgroundDrawable” with the same image it ends up stretched …

The result with “setBackgroundResource” on the left, “setBackgroundDrawable” on the right :

https://i.stack.imgur.com/yQi5n.jpg
(sorry I’m not allowed to post images here …)

The code :

View chips = EditChipsActivity.this.findViewById(mydID);
chips.setBackgroundResource(R.drawable.chips_filter);

VS :

View chips = EditChipsActivity.this.findViewById(mydID);
Bitmap bkg = ((BitmapDrawable) getResources().getDrawable(R.drawable.chips_filter)).getBitmap();
BitmapDrawable bkg = new BitmapDrawable(bkg);
chips.setBackgroundDrawable(bkg);

(I have to create my own bitmap and use the setBackgroundDrawable because I want to draw on the background)

  • 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-01T20:48:32+00:00Added an answer on June 1, 2026 at 8:48 pm

    Try this:

    View chips = (EditText) findViewById(R.id.editText1);
        Bitmap bkg = ((BitmapDrawable) getResources().getDrawable(R.drawable.chips_filter)).getBitmap();
        BitmapDrawable bkgbt = new BitmapDrawable(getResources(),bkg);
        chips.setBackgroundDrawable((Drawable) bkgbt);
    

    And your EditText:

    <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
        </EditText>
    

    I’m not if this do what you want….

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

Sidebar

Related Questions

I had set background image for Edittext. But when the user clicks on edittext
Possible Duplicate: How to set background image of a view? How to set UIView
I want to set background image to right and top of my span because
I want to set a background image to different divs, but my problems are:
I add the following code to main.xml to set an image as a background
Any idea how to set background color of a UIButton? I tried to use
I want to set the background color of JButton. For that I use setBackground()
Is there a way to set the background text of an EditText? for instance,
I have set the image in background, when i open the keyboard the image
Aim :- to set background image in my application that fills the device both

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.