From 6f9384039a155a0dc9f035c0d01a036b0ffb2def Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 15:01:51 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AB=E3=82=B9=E3=82=BF=E3=83=A0=E3=82=BF?= =?UTF-8?q?=E3=83=96=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6=E3=83=88=E5=AE=9F?= =?UTF-8?q?=E8=A3=85=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/viewer/ViewerContainerFragment.java | 10 +++++++++- .../src/main/res/layout/fragment_viewer_container.xml | 4 +++- .../viewer/src/main/res/layout/viewer_custom_tab.xml | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index 19ab6bd1..f85fca95 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -9,6 +9,7 @@ import androidx.viewpager2.widget.ViewPager2; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; import android.widget.Toast; import com.google.android.material.dialog.MaterialAlertDialogBuilder; @@ -130,7 +131,14 @@ public class ViewerContainerFragment extends Fragment { } // Attach tab layout to view pager - new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(viewerViewPagerAdapter.getTabTitle(position))).attach(); + new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> { + View customView = LayoutInflater.from(getContext()).inflate(R.layout.viewer_custom_tab, null); + + TextView textView = customView.findViewById(R.id.tab_title); + textView.setText(viewerViewPagerAdapter.getTabTitle(position)); + + tab.setCustomView(customView); + }).attach(); } /** diff --git a/component/viewer/src/main/res/layout/fragment_viewer_container.xml b/component/viewer/src/main/res/layout/fragment_viewer_container.xml index 2be3e503..12ed3204 100644 --- a/component/viewer/src/main/res/layout/fragment_viewer_container.xml +++ b/component/viewer/src/main/res/layout/fragment_viewer_container.xml @@ -40,7 +40,9 @@ + android:layout_height="wrap_content" + app:tabMode="scrollable" + />