mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 17:53:14 +00:00
ステータスバーの色を合わせる処理を移植
This commit is contained in:
parent
3b684bec53
commit
20828e2f0f
|
@ -150,6 +150,25 @@ public class LibraryPageFragment extends Fragment {
|
||||||
this.currentTotalItemCount = libraryItemPage.getListItems().size();
|
this.currentTotalItemCount = libraryItemPage.getListItems().size();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Set status bar color
|
||||||
|
AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout);
|
||||||
|
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
|
||||||
|
@Override
|
||||||
|
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
||||||
|
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
|
||||||
|
// Collapsed
|
||||||
|
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
|
||||||
|
} else if (verticalOffset == 0) {
|
||||||
|
// Expanded
|
||||||
|
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSurface));
|
||||||
|
} else {
|
||||||
|
// Somewhere in between
|
||||||
|
// Here you can add a color transition if you want
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/library_toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
app:layout_collapseMode="pin"
|
app:layout_collapseMode="pin"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user