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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:30:56+00:00 2026-06-16T21:30:56+00:00

I have a tileable image I would like to use as the background of

  • 0

I have a tileable image I would like to use as the background of a ListView. I have already set setCacheColorHint(android.R.color.transparent) in order to view the background image properly, using setBackgroundDrawable().

My problem is the when I scroll the ListView, the image stays in-place and doesn’t scroll too. I’m assuming this is normal behaviour, but I would like the image to scroll with the text.

Is there any way to do that without resorting to rolling my own ListView or setting the background of every cell’s view? I’m not using XML for this, as I would like this to be dynamic.

  • 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-16T21:30:58+00:00Added an answer on June 16, 2026 at 9:30 pm

    Create one class and extends it with ListView ::

    public class MyCustomListView extends ListView
    {
            private Bitmap background;
    
            public MyCustomListView(Context context, AttributeSet attrs) 
            {
                super(context, attrs);
                background = BitmapFactory.decodeResource(getResources(), R.drawable.yourImage);//yourImage means your listView Background which you want to move
            }
    
            @Override
            protected void dispatchDraw(Canvas canvas) 
            {
                int count = getChildCount();
                int top = count > 0 ? getChildAt(0).getTop() : 0;
                int backgroundWidth = background.getWidth();
                int backgroundHeight = background.getHeight();
                int width = getWidth();
                int height = getHeight();
    
                for (int y = top; y < height; y += backgroundHeight)
                {
                    for (int x = 0; x < width; x += backgroundWidth)
                    {
                        canvas.drawBitmap(background, x, y, null);
                    }
                }
                super.dispatchDraw(canvas);
            }
    }
    

    Now in your XML File ,take one listiview like this ::
    //Set other attributes as per your requirement

     <com.test.MyCustomListView
        android:id="@+id/listview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
     </com.test.MyCustomListView>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
Have a look at the menu link Produkter on http://marckmann.se/ I would like to
Have found maven to use hard for simple things like jar-signing ..May be I
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
have a nice day. I got problem when trying to create an image from
Have to set expiry date for my app. At present, I am storing the
Have a look at my AndroidMenifest.xml <?xml version=1.0 encoding=utf-8?> <manifest xmlns:android=http://schemas.android.com/apk/res/android package=com.myapp android:versionCode=1 android:versionName=1.0
have a little question concerning image icons in java and how to put a
Have the following cronjob set up in root's crontab: (centos 5.x) 2 * *
Have a long running set of discrete tasks: parsing 10s of thousands of lines

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.