[app] Add collapsing toolbar to settings

This commit is contained in:
NekoInverter 2021-10-14 18:51:34 +08:00 committed by LoveSy
parent 2388517b96
commit 0ea767cbf4
3 changed files with 15 additions and 17 deletions

View File

@ -72,8 +72,6 @@ public class SettingsFragment extends BaseFragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = FragmentSettingsBinding.inflate(inflater, container, false);
binding.getRoot().bringChildToFront(binding.appBar);
binding.appBar.setLiftable(true);
setupToolbar(binding.toolbar, R.string.Settings);
if (savedInstanceState == null) {
getChildFragmentManager().beginTransaction()
@ -309,12 +307,6 @@ public class SettingsFragment extends BaseFragment {
public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
BorderRecyclerView recyclerView = (BorderRecyclerView) super.onCreateRecyclerView(inflater, parent, savedInstanceState);
RecyclerViewKt.fixEdgeEffect(recyclerView, false, true);
recyclerView.getBorderViewDelegate().setBorderVisibilityChangedListener((top, oldTop, bottom, oldBottom) -> {
SettingsFragment fragment = (SettingsFragment) getParentFragment();
if (fragment != null) {
fragment.binding.appBar.setLifted(!top);
}
});
return recyclerView;
}
@ -329,7 +321,7 @@ public class SettingsFragment extends BaseFragment {
final String reference;
try {
reference = ctx.createConfigurationContext(conf).getString(id);
} catch(NotFoundException nfe) {
} catch (NotFoundException nfe) {
return lstLang; // return only english
}

View File

@ -33,18 +33,25 @@
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:elevation="0dp" />
android:layout_height="?attr/collapsingToolbarLayoutMediumSize"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="0dp"
app:layout_collapseMode="pin" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -26,12 +26,11 @@
android:layout_height="match_parent"
android:clipToPadding="false"
android:fadeScrollbars="true"
android:paddingTop="?actionBarSize"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
app:borderBottomVisibility="never"
app:borderTopDrawable="@null"
app:borderTopVisibility="whenTop"
app:fitsSystemWindowsInsets="bottom|top"
app:fitsSystemWindowsInsets="bottom"
tools:ignore="UnusedResources"
tools:viewBindingIgnore="true" />