Android ListView Style

I have a question about list views. Hope someone knows the solution because I tried to solve this problem all weekend.

I have my own list view in which each line has a custom .xml( item_row.xml) with the background color set for the line item.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="70dip"
  android:orientation="vertical"
  android:background="@drawable/list_bg">

The problem is that when I try to make a selector for a list. I want two things:

  • When the subject is focused, a typical orange rectangle should appear on it,
  • and the same when the item is pressed.

I proved that with a selector and a custom style, but everything I get is either a selector not showing, or a selector closing an element, so I don't see it.

If anyone could help me find the right code, I would be very grateful.

thank

+3
2

ListView.

android:listSelector="@drawable/list_bg"

, XML . API- API Demo.

+6

backgronud , : listSelector. .

+3

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


All Articles