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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:16:52+00:00 2026-05-21T20:16:52+00:00

I want to set a background image to my listview so that regardless of

  • 0

I want to set a background image to my listview so that regardless of where you are in the list, you see the same background image.

For scrollview, this is just a case of setting the background image of the scrollview in the XML attributes, but doing likewise for the listview doesn’t work

I’m using a custom ArrayAdapter as such:

private class CustomAdapter extends ArrayAdapter<TableRow>{

    private ArrayList<TableRow> items;

    public CustomAdapter(Context context, int textViewResourceId, ArrayList<TableRow> items) {
            super(context, textViewResourceId, items);
            this.items = items;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
            View v = convertView;
            if (v == null) {
                LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.list_season, null);
            }
            TableRow o = items.get(position);
            if (o != null) {
                v = o;
            }

            return v;
    }


}

and then

ListView lv = new ListView(this);
lv.setId(R.id.list_listView1);

ArrayList<TableRow> tablerows = new ArrayList<TableRow>();    

// create some TableRow's and add them to tablerows

CustomAdapter vAdapt = new CustomAdapter(this, R.id.list_season_item_name,tablerows);

lv.setAdapter(vAdapt);

setContentView(lv);

and my xml:

<ListView 
android:id="@+id/list_listView1" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/standard_layout">
<LinearLayout 
    android:id="@+id/list_linearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/standard_layout">
    <TextView 
        android:text="list_textview1" 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content">
    </TextView>
</LinearLayout>

and also

<?xml version="1.0" encoding="utf-8"?>

<TableRow
        xmlns:android="http://schemas.android.com/apk/res/android"          
        android:layout_width="fill_parent" 
        android:layout_alignParentLeft="true" 
        android:id="@+id/list_season_row" 
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:paddingTop="10dip"
        android:paddingLeft="15dip"
        android:paddingBottom="10dip">
        <TextView
            android:layout_weight="3"
            android:layout_width="0dip"
            android:paddingRight="10dip"  
            android:id="@+id/list_season_item_name" 
            android:layout_height="wrap_content"
            style="@style/standard_item">
        </TextView>
        <TextView
            android:paddingLeft="10dip"
            android:layout_weight="1" 
            android:id="@+id/list_season_item_season" 
            android:gravity="left" 
            android:layout_gravity="right"
            android:layout_width="0dip" 
            android:layout_height="wrap_content"
            style="@style/standard_season">
        </TextView>
    </TableRow>

and my styles

<style name="standard_item" parent="@style/standard_font">
    <item name="android:textSize">18sp</item>
</style>
<style name="standard_season" parent="@style/standard_font">
    <item name="android:textSize">12sp</item>
</style>

<style name="standard_layout" parent="@style/standard_font">
    <item name="android:background">@drawable/background_img</item>
</style>

Setting a style for each TableRow just makes each one use the whole background image, which is not what I’m after.

Also there is probably a better way to implement my ArrayAdapter but I’m not keen on changing it unless there is no other way to get the effect I’m after

This has been bugging me for a while, so any help would be appreciated,

Thanks
Spoon Thumb

  • 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-21T20:16:53+00:00Added an answer on May 21, 2026 at 8:16 pm

    Disable the default ListView cache color hint optimization by making it transparent:

    <style name="standard_layout" parent="@style/standard_font">
        <item name="android:background">@drawable/background_img</item>
        <item name="android:cacheColorHint">@android:color/transparent</item>
    </style>
    

    See http://android-developers.blogspot.com/2009/01/why-is-my-list-black-android.html

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

Sidebar

Related Questions

I want to set an background to my listview that have different size (depending
I want to set the background image of a ListView control in my Shell
I set a image as Listview background, if I want to scroll it with
I want to set a background image to my Activity. I am just using
I want to set a background image for a div, in a way that
i want to set same background image to all my app layouts. My app
I want to set a background image for my form/window like this guy but
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 want to place links over a background image (set in CSS) and I

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.