Skip to content

Commit

Permalink
fix(android): switch TabLayout gravity when changing orientation (#10687
Browse files Browse the repository at this point in the history
)

Takes care of switching a TabLayout's TabGravity depending on current orientation.

Fixes TIMOB-26698
  • Loading branch information
ypbnv authored and sgtcoolguy committed Mar 25, 2019
1 parent bf6530e commit d020851
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package ti.modules.titanium.ui.widget.tabgroup;

import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.graphics.Rect;
import android.support.design.widget.TabLayout;
Expand Down Expand Up @@ -124,6 +125,17 @@ protected void onLayout(boolean hasChanged, int left, int top, int right, int bo
super.onLayout(hasChanged, left, top, right, bottom);
insetsProvider.setTopBasedOn(this);
}

@Override
protected void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
setTabGravity(TabLayout.GRAVITY_FILL);
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
setTabGravity(TabLayout.GRAVITY_CENTER);
}
}
};
this.mTabLayout.setFitsSystemWindows(true);

Expand Down

0 comments on commit d020851

Please sign in to comment.