By default, ListView changes background color to orange on being pressed and also the TextColor of TextView changes to white/black. By applying a selector on a ListView item we can set background color for pressed state but can we also define the TextColor for the TextView inside that item/layout within same selector? If so, then how?
By default, ListView changes background color to orange on being pressed and also the
Share
Amy88’s answer resolved the problem, but doesn’t specifically address changing a ViewGroup’s child’s properties.
Suppose you have a clickable
LinearLayoutwith aTextViewwhich should change color when pressed. The key is to useandroid:duplicateParentState="true"on the child views:You can specify the selector as in Amy88’s answer.