How can we change Selected Tablayout Icon and Text color in android -
hi new android , in app have change selected tablayout icon , text colors blue , remaining unselected icon , text colors should white wrote below code here changing icon color how can change text color also
my code:-
setupviewpager(viewpager); tablayout = (tablayout) findviewbyid(r.id.tabs); tablayout.setupwithviewpager(viewpager); tablayout.setontabselectedlistener( new tablayout.viewpagerontabselectedlistener(viewpager) { @override public void ontabselected(tablayout.tab tab) { super.ontabselected(tab); int tabiconcolor = contextcompat.getcolor(context, r.color.tabselectediconcolor); tab.geticon().setcolorfilter(tabiconcolor, porterduff.mode.src_in); } @override public void ontabunselected(tablayout.tab tab) { super.ontabunselected(tab); int tabiconcolor = contextcompat.getcolor(context, r.color.tabunselectediconcolor); tab.geticon().setcolorfilter(tabiconcolor, porterduff.mode.src_in); } @override public void ontabreselected(tablayout.tab tab) { super.ontabreselected(tab); } } );
screen:-
try use below solution in tablayout
<android.support.design.widget.tablayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabmode="fixed" app:tabtextcolor="@color/colortabnotselect" app:tabselectedtextcolor="@color/coloraccent" android:background="#fff" app:tabgravity="fill"/>
i hope work you.
Comments
Post a Comment