[app] Set tabLayout scrollable (#880)
This commit is contained in:
parent
acb5b34f2f
commit
b7ee496016
|
|
@ -93,6 +93,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import rikka.core.res.ResourcesKt;
|
||||
import rikka.insets.WindowInsetsHelperKt;
|
||||
|
|
@ -208,6 +209,15 @@ public class ModulesFragment extends BaseFragment implements ModuleUtil.ModuleLi
|
|||
}
|
||||
}
|
||||
|
||||
binding.tabLayout.addOnLayoutChangeListener((view, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
|
||||
ViewGroup vg = (ViewGroup) binding.tabLayout.getChildAt(0);
|
||||
int tabLayoutWidth = IntStream.range(0, binding.tabLayout.getTabCount()).map(i -> vg.getChildAt(i).getWidth()).sum();
|
||||
if (tabLayoutWidth <= binding.getRoot().getWidth()) {
|
||||
binding.tabLayout.setTabMode(binding.tabLayout.MODE_FIXED);
|
||||
binding.tabLayout.setTabGravity(binding.tabLayout.GRAVITY_FILL);
|
||||
}
|
||||
});
|
||||
|
||||
binding.fab.setOnClickListener(v -> {
|
||||
var pickAdaptor = new ModuleAdapter(null, true);
|
||||
var position = binding.viewPager.getCurrentItem();
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@
|
|||
android:id="@+id/tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/tab_layout_height"
|
||||
app:tabMode="scrollable"
|
||||
app:tabGravity="center"
|
||||
android:background="@android:color/transparent"
|
||||
app:tabIndicatorAnimationMode="elastic" />
|
||||
</LinearLayout>
|
||||
|
|
|
|||
Loading…
Reference in New Issue