From fda8adae801b5f637a6f067ca545d7f272f004a0 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 05:23:21 +0900 Subject: [PATCH] =?UTF-8?q?UI=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/setting/SettingTopFragment.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTopFragment.java b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTopFragment.java index 14b1bd06..7b0b237d 100644 --- a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTopFragment.java +++ b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTopFragment.java @@ -10,6 +10,8 @@ import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.appbar.AppBarLayout; + import java.util.ArrayList; import one.nem.lacerta.setting.model.SettingListItem; @@ -86,6 +88,23 @@ public class SettingTopFragment extends Fragment { recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(new ListItemAdapter(settingListItems)); + // 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 + } + } + }); return view; } } \ No newline at end of file