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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:13:50+00:00 2026-06-06T10:13:50+00:00

This is my custom selector (StateListDrawable) <selector xmlns:android=http://schemas.android.com/apk/res/android> <item android:drawable=@drawable/common_cell_background /> <item android:state_pressed=true android:drawable=@drawable/common_cell_background_highlight

  • 0

This is my custom selector (StateListDrawable)

<selector
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:drawable="@drawable/common_cell_background" />
    <item
        android:state_pressed="true"
        android:drawable="@drawable/common_cell_background_highlight" />
    <item
        android:state_focused="true"
        android:drawable="@drawable/common_cell_background_highlight" />
    <item
        android:state_selected="true"
        android:drawable="@drawable/common_cell_background_highlight" />
</selector>

Both, common_cell_background and common_cell_background_highlight are XML. Code below:

common_cell_background.xml

<bitmap
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/common_cell_background_bitmap"
    android:tileMode="repeat"
    android:dither="true">
</bitmap>

common_cell_background_highlight.xml

<bitmap
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/common_cell_background_bitmap_highlight"
    android:tileMode="repeat"
    android:dither="true">
</bitmap>

Bitmaps are also exactly the same. Highlight is just a little bit lighter and there is no other differences. Both bitmaps are PNG files.

Now I set

convertView.setBackgroundResource(R.drawable.list_item_background);

and here is the problem. My common_cell_background doesn’t repeat, it’s stretched. But what is suprising when I touch on cell of my list background changes to common_cell_background_highlight and guess what? Everything is fine, it’s repeated like it should be. I have no idea where is the problem, why my background doesn’t repeat while highlight does. Any 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-06T10:13:54+00:00Added an answer on June 6, 2026 at 10:13 am

    This is the bug, it was fixed in ICS, see this answer: https://stackoverflow.com/a/7615120/1037294

    Here is a workaround: https://stackoverflow.com/a/9500334/1037294

    Note, that the workaround is only applicable for BitmapDrawable, for other types of drawables like StateListDrawable you’ll need to do extra work. Here is what I use:

    public static void fixBackgrndTileMode(View view, TileMode tileModeX, TileMode tileModeY) {
        if (view != null) {
            Drawable bg = view.getBackground();
    
            if (bg instanceof BitmapDrawable) {
                BitmapDrawable bmp = (BitmapDrawable) bg;
                bmp.mutate(); // make sure that we aren't sharing state anymore
                bmp.setTileModeXY(tileModeX, tileModeY);
            }
            else if (bg instanceof StateListDrawable) {
                StateListDrawable stateDrwbl = (StateListDrawable) bg;
                stateDrwbl.mutate(); // make sure that we aren't sharing state anymore
    
                ConstantState constantState = stateDrwbl.getConstantState();
                if (constantState instanceof DrawableContainerState) {
                    DrawableContainerState drwblContainerState = (DrawableContainerState)constantState;
                    final Drawable[] drawables = drwblContainerState.getChildren();
                    for (Drawable drwbl : drawables) {
                        if (drwbl instanceof BitmapDrawable)
                            ((BitmapDrawable)drwbl).setTileModeXY(tileModeX, tileModeY);
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a custom buttom with a selector: <?xml version=1.0 encoding=utf-8?> <selector xmlns:android=http://schemas.android.com/apk/res/android> <item
A web service return to my flex3 client this custom exception: <SOAP-ENV:Fault xmlns:ro=urn:Gov2gLibrary xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/
I used this source http://www.cats.rwth-aachen.de/library/programming/cocoa to create my custom sheet. I created a NSPanel
I used this selector code for my custom button (simple.xml) <?xml version=1.0 encoding=utf-8?> <selector
var selector = $(this); What is the proper code to change the custom attribute
I have this custom textbox that I am working on and I can use
Is there a standard method I can use in place of this custom method?
I have a ListView which contains custom rows. This custom row has following UI
I am leaking memory on this: my custom class: + (id)vectorWithX:(float)dimx Y:(float)dimy{ return [[[Vector
Is it possible to have nested set capabilities in this somewhat custom setup? Consider

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.