Skip to content Skip to sidebar Skip to footer

Difference Between Tinting A Child View And The Containing Viewgroup

I'm trying to better understand the following situation that arose while refactoring some 'selection highlighting' code (to take advantage of tinting). There's a list that's popula

Solution 1:

Why if in option 2 the background must be explicitly set (or else tv.Background.SetTintList(_csl); throws null ex), but in option 1 item_header_tv's background get's highlighted?

The first works because you've set android:background="#FFFFFFFF" to the LinearLayout, the code v = _._inflater.Inflate(_listItemRes, parent, false); points to the this LinearLayout. So it's background is not omitted/null.

The Background cannot be null if you want to SetTintList, the second line doesn't work because Background of your TextView v is null.

By the way, controls like Button has Background set by default, you don't need to specify the Background property for them to use SetTintList.

Post a Comment for "Difference Between Tinting A Child View And The Containing Viewgroup"