1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

hide main page tab selector with single tab

This commit is contained in:
Paweł Matuszewski 2019-12-15 12:41:19 +01:00 committed by TobiGr
parent 33caad4690
commit f0f0c43b72

View File

@ -14,6 +14,7 @@ import com.google.android.material.tabs.TabLayout.Tab;
/** /**
* A TabLayout that is scrollable when tabs exceed its width. * A TabLayout that is scrollable when tabs exceed its width.
* Hides when there are less than 2 tabs.
*/ */
public class ScrollableTabLayout extends TabLayout { public class ScrollableTabLayout extends TabLayout {
private static final String TAG = ScrollableTabLayout.class.getSimpleName(); private static final String TAG = ScrollableTabLayout.class.getSimpleName();
@ -60,6 +61,13 @@ public class ScrollableTabLayout extends TabLayout {
} }
private void resetMode() { private void resetMode() {
if (getTabCount() < 2) {
setVisibility(View.GONE);
return;
} else {
setVisibility(View.VISIBLE);
}
if (getTabCount() == 0 || getTabAt(0).view == null) return; if (getTabCount() == 0 || getTabAt(0).view == null) return;
setTabMode(TabLayout.MODE_FIXED); setTabMode(TabLayout.MODE_FIXED);