How to disable this highlight on pressing the tab. I have been searching for half an hour and couldn't figure it out. I am using tablayout.
Remove highlight on press in tablayout
Asked Answered
just set the background color to transparent or to the background color of the tablayout. Add the following code to the parent layout.
xmlns:app="http://schemas.android.com/apk/res-auto"
And add the following to tablayout.
app:tabBackground="?attr/colorPrimary"
android:background="?attr/colorPrimary"
This will solve your problem. Tested in Android M.
In my xml I have Toolbar and TabLayout and ViewPager. Toolbar and Tablayout have their backgrounds set but it still highlights on press. Maybe I am doing something wrong. –
Continuo
add the following code to parent layout xmlns:app="schemas.android.com/apk/res-auto" and the following code to the tablayout app:tabBackground="?attr/colorPrimary" android:background="?attr/colorPrimary" Tested with the android version M and it is working. –
Vareck
app:tabBackground saved the day. Thanks. –
Continuo
Add the below line to your XML:
app:tabRippleColor="@android:color/transparent"
This should be added to the excepted answer. I was only able to remove all background highlights after also making the ripple transparent. Thanks! –
Aloise
If you want to disable color when unselected tab is selected,i.e: android:state_focused="true", then this is the solution. Thank you sir for this solution! –
Trainee
it's the wrong answer. The correct answer is not to hardcode this attribute –
Bough
just set the background color to transparent or to the background color of the tablayout. Add the following code to the parent layout.
xmlns:app="http://schemas.android.com/apk/res-auto"
And add the following to tablayout.
app:tabBackground="?attr/colorPrimary"
android:background="?attr/colorPrimary"
This will solve your problem. Tested in Android M.
In my xml I have Toolbar and TabLayout and ViewPager. Toolbar and Tablayout have their backgrounds set but it still highlights on press. Maybe I am doing something wrong. –
Continuo
add the following code to parent layout xmlns:app="schemas.android.com/apk/res-auto" and the following code to the tablayout app:tabBackground="?attr/colorPrimary" android:background="?attr/colorPrimary" Tested with the android version M and it is working. –
Vareck
app:tabBackground saved the day. Thanks. –
Continuo
© 2022 - 2024 — McMap. All rights reserved.