适配优化
This commit is contained in:
@@ -27,7 +27,7 @@ class SearchAdapter(list: MutableList<SearchModel>) :
|
||||
override fun onBindViewHolder(holder: VH, position: Int, item: SearchModel?) {
|
||||
val binding = holder.binding
|
||||
binding.btnFoodName.run {
|
||||
text = item!!.foodName
|
||||
text = " ${item!!.foodName}"
|
||||
setTextColor(
|
||||
getColor(if (item.isClicked) R.color.shelf_name_blue else R.color.black999)
|
||||
)
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package com.shuwei.intelligent.shelves.base
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import android.view.WindowInsetsController
|
||||
import android.widget.TextView
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.gyf.immersionbar.BarHide
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.shuwei.intelligent.shelves.R
|
||||
import com.shuwei.intelligent.shelves.databinding.ActivityBaseBinding
|
||||
|
||||
@@ -33,7 +38,7 @@ open class BaseActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityBaseBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
statusBarDarkFont(enable = false)
|
||||
statusBarDarkFont()
|
||||
launcher =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
if (result.resultCode == RESULT_OK) {
|
||||
@@ -41,22 +46,29 @@ open class BaseActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
// window.setDecorFitsSystemWindows(false) // 启用 Edge-to-Edge
|
||||
// window.insetsController?.apply {
|
||||
// hide(WindowInsets.Type.statusBars()) // 隐藏状态栏
|
||||
// systemBarsBehavior =
|
||||
// WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE // 滑动时临时显示
|
||||
// }
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
window.setDecorFitsSystemWindows(false)
|
||||
window.insetsController?.apply {
|
||||
hide(WindowInsets.Type.statusBars()) // 隐藏状态栏
|
||||
systemBarsBehavior =
|
||||
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE // 滑动时临时显示
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun hideStatusBar() {
|
||||
enableEdgeToEdge()
|
||||
// enableEdgeToEdge()
|
||||
// val uiOptions = (View.SYSTEM_UI_FLAG_FULLSCREEN // 隐藏状态栏
|
||||
// or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) // 隐藏导航栏(可选)
|
||||
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
// window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
|
||||
ImmersionBar.with(this)
|
||||
.hideBar(BarHide.FLAG_HIDE_STATUS_BAR)
|
||||
.init()
|
||||
}
|
||||
|
||||
fun statusBarDarkFont(enable: Boolean) {
|
||||
fun statusBarDarkFont() {
|
||||
//window.decorView.systemUiVisibility = if (enable) View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR else 0
|
||||
val color = ContextCompat.getColor(this, R.color.white)
|
||||
binding.tvLeftStatus.setTextColor(color)
|
||||
|
||||
Reference in New Issue
Block a user