作者 liyan

修改BaseFragment2

... ... @@ -43,7 +43,7 @@ abstract class BaseFragment : Fragment() {
if (Date().month + 1 == 4 && Date().date == 4) {
// initStatusColor(getColor(requireContext(), R.color.colorGray666))
} else {
initStatusColor(0)
// initStatusColor(0)
}
initView()
initData()
... ... @@ -58,20 +58,20 @@ abstract class BaseFragment : Fragment() {
private fun initStatusColor(color: Int) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// requireActivity().window.statusBarColor = if (color == 0) ColorUtil.getColor(requireContext()) else color
}
if (ColorUtils.calculateLuminance(Color.TRANSPARENT) >= 0.5) {
// 设置状态栏中字体的颜色为黑色
requireActivity().window.decorView.systemUiVisibility =
View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
} else {
// 跟随系统
requireActivity().window.decorView.systemUiVisibility =
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
}
}
// private fun initStatusColor(color: Int) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//// requireActivity().window.statusBarColor = if (color == 0) ColorUtil.getColor(requireContext()) else color
// }
// if (ColorUtils.calculateLuminance(Color.TRANSPARENT) >= 0.5) {
// // 设置状态栏中字体的颜色为黑色
// requireActivity().window.decorView.systemUiVisibility =
// View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
// } else {
// // 跟随系统
// requireActivity().window.decorView.systemUiVisibility =
// View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// }
// }
override fun onDestroyView() {
super.onDestroyView()
... ...
... ... @@ -36,11 +36,19 @@ import com.youth.banner.indicator.CircleIndicator
* auth:张继
* des:
*/
class HomeFragment : BaseLifeCycleFragment<MineViewModel,FragmentHomeBinding>(FragmentHomeBinding::inflate) {
class HomeFragment : BaseLifeCycleFragment<MineViewModel,FragmentHomeBinding>(FragmentHomeBinding::inflate){
override fun initDataObserver() {
}
// override fun initImmersionBar() {
// ImmersionBar.with(this).statusBarColor(R.color.color_25).statusBarDarkFont(true).init()
// }
//
// override fun immersionBarEnabled(): Boolean {
// return true
// }
}
//class HomeFragment : Fragment() {
// override fun onCreateView(
... ...
... ... @@ -6,6 +6,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
... ...
... ... @@ -3,4 +3,4 @@
android:id="@+id/status_bar"
android:layout_width="match_parent"
android:layout_height="24dp"
android:background="@android:color/transparent" />
\ No newline at end of file
android:background="@color/color_25" />
\ No newline at end of file
... ...