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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:26:39+00:00 2026-05-24T04:26:39+00:00

What I need to do is have the background image just fill up the

  • 0

What I need to do is have the background image just fill up the natural size of the button, as when no background is specified and the default grey background image is shown. But instead, my button scales up to the size of the background image rather than the text.

There was a previous question, but nobody had a solution.

The button:

enter image description here

<Button
    android:id="@+id/morebtn"
    style="@style/CustomButton"
    android:text="More" />

I have this custom button style (greybutton is a 9-patch):

<resources>
    <style name="CustomButton" parent="@android:style/TextAppearance">
        <item name="android:textColor">#FFFFFF</item>
        <item name="android:layout_marginLeft">10dip</item>
        <item name="android:layout_marginRight">10dip</item>
        <item name="android:layout_marginBottom">10dip</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_centerInParent">true</item>
        <item name="android:background">@drawable/greybutton</item>
        <item name="android:textSize">20sp</item>
    </style>
</resources>

Right now it fills up the screen widthwise, despite being told to wrap_content. When I remove android:background from the Button style, the button shrinks down to wrap the text as expected.

Does anyone see why my background image isn’t behaving like the default Button 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-05-24T04:26:41+00:00Added an answer on May 24, 2026 at 4:26 am

    Damnit. I had an hdpi drawable that hadn’t been converted to 9patch, and for some reason that was getting applied instead of the one in the mdpi drawables folder even on my mdpi screen. The background scaling actually does work as expected after all. Sorry!

    (So if you’re browsing this question with a similar problem, check your drawables folder to make sure you’re drawing what you think you are. Also: may wish to be sure the content boundaries in your nine-patch are of the appropriate size. Note that they aren’t the same as the stretchable boundaries.)

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

Sidebar

Related Questions

Basically I need this: http://plugins.jquery.com/project/maphilight ...but instead of just having the <AREA> tags recieve
if i have a php background job, may need to run 4-5hours or more
I need change background of all text that have two spaces from the start
I'm learning Objective-C, and have a C/C++ background. In object-oriented C++, you always need
I have a complex background image and images, that should be on exact positions
I need to have an image at the top-center of a web page in
I need to make a css background image fade slideshow. For several reasons, i
In my application I have an image (world map) as background picture. Over this
I have a rollover image that makes use of a large background image that
I need to style a table to have rounded corners. I'm just looking at

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.