material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.37k stars 3.07k forks source link

[TabLayout] Property "app:tabIndicator" is tinting every activity background/fragment after be rendered #963

Closed pedrofsn closed 4 years ago

pedrofsn commented 4 years ago

Description: I've an activity with bottom navigation and one framelayout (to inflate fragments). When I inflate the second fragment, it has an TabLayout, every screen has the background tinted with theme accent color. It's not happening with just one or more fragments, includes activities openned later too.

Other scenario: I open XActivity. Everything is fine. I inflate the fragment (that have the tablayout) and open the same XActivity, now the background is tinted.

Source code: When I got this problem I started to remove every screen element and customization (after review styles, manifest etc) and I discovered the problem is happening with one specific property, app:tabIndicator.

Android API version: compileSDK, targetSDK = 29 ; minSDK = 21

Material Library version: com.google.android.material:material:1.2.0-alpha04 and happening too with com.google.android.material:material:1.2.0-alpha03. I didn't tested other versions.

Device: Happen in any device such as Asus Zenfone 5Z, Motorola Moto G5, Simulator etc.

Solution: Remove property app:tabIndicator from XML and set programmatically in Kotlin/Java. E.g.: binding.tabLayout.setSelectedTabIndicatorColor(ContextCompat.getColor(activity as Context, android.R.color.white))

ikim24 commented 4 years ago

Hi @pedrofsn Can you include a sample that shows app:tabIndicator tinting activities? Thanks!