Can I change the Android style in ListView style without creating a custom list?

I would like to change the color of the text and background of my list without creating custom strings. Is it possible?

Here is my code that DOES NOT work.

<ListView
    android:id="@android:id/list"
    android:textColor="#000000"           
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:cacheColorHint="#000000"/>

Any help would be appreciated.

thank

+3
source share
1 answer

First of all, cacheColorHintit has nothing to do with style. Try a presentation of the Romain Guy ListView on GoogleIO 2010 . You will understand a lot with this.

About Style:

I changed a few things in my application.

View in ListView:

<ListView android:id="@id/android:list"
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent"
  android:layout_weight="1"
  android:headerDividersEnabled="false"
  android:footerDividersEnabled="true"
  android:divider="@drawable/list_divider"
  android:dividerHeight="1dip"
  android:cacheColorHint="#FFFFFF"
/>

Short explanation: I just walked out of the footer and changed my delimiter to a gradient.

hood / list_divider:

<?xml version="1.0" encoding="utf-8"?>
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape>
            <gradient
                android:startColor="#000000"
                android:centerColor="#CCCCCC"
                android:endColor="#FFFFFF"
                android:height="1px"
                android:angle="0" />
        </shape>
    </item>
</layer-list>

RowLayout:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:paddingTop="2dp"
    android:paddingBottom="2dp"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:background="@android:color/white">

: .

+10

Source: https://habr.com/ru/post/1751874/


All Articles