Orbit
Orbit

Reputation: 2385

Removing margin between Toolbar and nested TabLayout?

So I have a TabLayout that is inside a Toolbar. I wanted to remove the overflow menu (three dots) so I commented out the onCreateOptionsMenu and onOptionsItemSelected methods that were auto-generated, to remove the icon (is this the proper way anyway?). Now there is a bit of a margin on the left side of the TabLayout. Here is a pic for reference: http://prntscr.com/8gf4c3

I have tried adding a negative margin to the TabLayout but that did not seem to work. I'd like the TabLayout to completely fill the Toolbar.

Any ideas?

Upvotes: 2

Views: 1071

Answers (1)

xiaomi
xiaomi

Reputation: 6703

To remove the left part, just use toolbar.setContentInsetsRelative(0, 0);

If you want to do the same but for xml, use android:contentInsetStart/Left="0dp"

https://developer.android.com/reference/android/support/v7/widget/Toolbar.html#setContentInsetsRelative%28int,%20int%29

Upvotes: 5

Related Questions