From f0f0c43b724f5945f9bdb471123079a7a8ce4bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Matuszewski?= Date: Sun, 15 Dec 2019 12:41:19 +0100 Subject: [PATCH] hide main page tab selector with single tab --- .../org/schabi/newpipe/views/ScrollableTabLayout.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/views/ScrollableTabLayout.java b/app/src/main/java/org/schabi/newpipe/views/ScrollableTabLayout.java index 88b108052..ffbb804af 100644 --- a/app/src/main/java/org/schabi/newpipe/views/ScrollableTabLayout.java +++ b/app/src/main/java/org/schabi/newpipe/views/ScrollableTabLayout.java @@ -14,6 +14,7 @@ import com.google.android.material.tabs.TabLayout.Tab; /** * A TabLayout that is scrollable when tabs exceed its width. + * Hides when there are less than 2 tabs. */ public class ScrollableTabLayout extends TabLayout { private static final String TAG = ScrollableTabLayout.class.getSimpleName(); @@ -60,6 +61,13 @@ public class ScrollableTabLayout extends TabLayout { } private void resetMode() { + if (getTabCount() < 2) { + setVisibility(View.GONE); + return; + } else { + setVisibility(View.VISIBLE); + } + if (getTabCount() == 0 || getTabAt(0).view == null) return; setTabMode(TabLayout.MODE_FIXED);