Android LinearLayout Selector background color

后端 未结 3 1956
攒了一身酷
攒了一身酷 2021-02-13 09:37

Hi I\'m trying to make my linear layout work like button. I mean I\'m trying to change its background color when the state is changed. I used selector to solve it, but it didn\'

3条回答
  •  失恋的感觉
    2021-02-13 10:22

    Although this question has answer I am writing this to clarify and give my observation.

    answer by @minelight does not work on views that are not clickable, for example LinearLayout and TextView. The statePressed state is available only for clickable views.

    The second answer actually completes the first one.

提交回复
热议问题