material-components / material-components-android

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

[TabLayout] Width of first tab is incorrect on some devices #1856

Open adil-hussain-84 opened 4 years ago

adil-hussain-84 commented 4 years ago

Description: A TabLayout which has a tabMode value of fixed and a tabGravity value of fill (as in the layout file here) results in the first tab rendering with a width of 264dp on some devices rather than its natural width, as this screenshot demonstrates.

Expected behavior: The first tab should have a natural width like the other two tabs in the TabLayout rather than a width of 264dp (which, curiously, is the value of the design_tab_max_width dimension in the com.google.android.material:material library).

Source code: See this minimal Android application which demonstrates the problem.

Android API version: Android 10

Material Library version: 1.2.1

Device: Moto G8 Plus landscape orientation

wcshi commented 4 years ago

Hi @adil-hussain-84 thank you for providing the sample apps, I don't have a Moto G8 plus device on hand, is this bug reproducible in an emulator?

adil-hussain-84 commented 4 years ago

@wcshi: Sadly, no. The only device that I've experienced it on yet is the Moto G8 Plus device, but that may be because I have a limited number of devices to hand. I have tried it in landscape on Android 10 and Android 11 emulators created with the Pixel 2 and Pixel 3 device definitions but I've not been able to replicate the issue there.

drchen commented 3 years ago

Is the issue still reproducible? If this only happens on a certain device/sdk combination it may not be Material library's issue.

adil-hussain-84 commented 3 years ago

Yes, the TabLayoutExperiments/app1 application module still demonstrates the issue despite updating both the build tools and libraries in the module to the latest versions.

The devices that I have to hand are the Google Pixel 4a, Moto E6 Plus, Moto G8 Plus and Galaxy Tab A7. Out of these, only the Moto G8 Plus demonstrates the issue.