Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SlidingTabLayout backgroundcolor

I am trying to change the tab background color of the SlidingTabLayout described in (https://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabLayout.html).

I managed to get the entire thing working. But when I change the tabresource color on line 183 for example:

 textView.setBackgroundResource(R.color.white);

The background of the tab becomes white, but the indicator does not appear at all.

Can someone please advise on how to just change the background color but have the indicator work as usual?

Thank you.

like image 586
AndroidP Avatar asked Sep 18 '26 00:09

AndroidP


1 Answers

Can't believe I missed this.

Put this in the constructor:

this.setBackgroundColor(context.getResources().getColor(R.color.tabBgColor));
like image 161
AndroidP Avatar answered Sep 20 '26 14:09

AndroidP



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!