mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
カスタムタブレイアウト実装 WIP
This commit is contained in:
parent
457eabcdf4
commit
6f9384039a
|
@ -9,6 +9,7 @@ import androidx.viewpager2.widget.ViewPager2;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
|
@ -130,7 +131,14 @@ public class ViewerContainerFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach tab layout to view pager
|
// 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -40,7 +40,9 @@
|
||||||
<com.google.android.material.tabs.TabLayout
|
<com.google.android.material.tabs.TabLayout
|
||||||
android:id="@+id/tab_layout"
|
android:id="@+id/tab_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
app:tabMode="scrollable"
|
||||||
|
/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/loading_progress_bar"
|
android:id="@+id/loading_progress_bar"
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView"
|
android:id="@+id/tab_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="TAB TITLE"
|
android:text="TAB TITLE"
|
||||||
android:layout_gravity="center"/>
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/imageButton"
|
android:id="@+id/tab_modify"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user