Seems like something that should be easy to find, but it's harder than I thought. What is the default height on the TabLayout in DIPs?
What is the default height on Androids TabLayout
how to set it to default height, I hate adding lot of custom heights as per different screen resolutions –
Glucinum
@ShirishHerwade If you set the height to wrap_content in xml, then it will automatically size to the default height. If you want to explicitly set a height, then set height to 48dp in xml. Using dp sizes it based on screen resolution.If you're trying to set the height dynamically, then you'll have to multiply your height by a float based on screen resolution. You can get the screen resolution using the line: getApplication.getResources().getDisplayMetrics().density; –
Platypus
Thanks wrap_content works –
Glucinum
material.io/guidelines/components/tabs.html#tabs-specs –
Ophthalmoscope
Material Design guidelines state that this height equals 48dp when You have text or image, and 72dp when You have image and text.
it seems like in my side it's different from phone to phone sometimes it's 35dp not sure why this happens. –
Irresponsible
its height is "?attr/tabIndicatorHeight"
E.g. you can use this value in an xml file for another view like:
android:layout_marginBottom="?attr/tabIndicatorHeight"
And it will look ok on all devices.
This is marked as deprecated:
Instead, set the intrinsic size of the custom drawable provided to the tabIndicator attribute in order to change the indicator height. For example, this can be done by setting the <size> property in a <shape> resource.
–
Dailey © 2022 - 2024 — McMap. All rights reserved.