PomeGranate PomeGranate - 1 year ago 115
Android Question

How can I set the height of tabs in Android a TabLayout?

I Have this TabLayout in Android and wanted to make the tabs a little heigher than the default (48dp)


Here is the Style Theme.Zhaw.TabLayout:

<style name="Theme.Zhaw.TabLayout" parent="Widget.Design.TabLayout">
<item name="tabIndicatorColor">@color/text_white</item>
<item name="tabIndicatorHeight">4dp</item>
<item name="tabPaddingStart">6dp</item>
<item name="tabPaddingEnd">6dp</item>
<item name="tabBackground">@color/colorPrimary</item>
<item name="tabTextAppearance">@style/Theme.Zhaw.TabLayoutText</item>
<item name="tabSelectedTextColor">@color/text_white</item>

tabIndicatorHeight can set the height of the small indicator (active tab) in the tab. but how can we set the height of the tab itself?

Answer Source

set a layout_height in dps instead of wrap_content this could differ in different display sizes but if you wanna set a height dynamically

getApplication.getResources().getDisplayMetrics() get your current height and calculate the height according to that

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download