cloudroam
2025-04-02 c517367a47022bedff70f708b2e57424611a642e
app/src/main/java/com/example/firstapp/ui/home/HomeFragment.kt
@@ -33,13 +33,12 @@
import com.example.firstapp.utils.PreferencesManager
import com.google.android.material.bottomsheet.BottomSheetDialog
import kotlinx.coroutines.launch
import com.example.firstapp.view.UnderlineTextView
class HomeFragment : Fragment() {
    private var _binding: FragmentHomeBinding? = null
    // This property is only valid between onCreateView and
    // onDestroyView.
    private val binding get() = _binding!!
    private lateinit var homeViewModel: HomeViewModel
@@ -274,13 +273,17 @@
        }
    }
    private fun updateTabStyles(selectedTab: TextView) {
    private fun updateTabStyles(selectedTab: UnderlineTextView) {
        binding.apply {
            val tabs = listOf(tabExpress, tabFinance, tabIncome, tabFlight, tabTrain)
            tabs.forEach { tab ->
                // 设置文字颜色为黑色或灰色
                tab.setTextColor(ContextCompat.getColor(requireContext(), 
                    if (tab == selectedTab) R.color.tab_selected else R.color.gray))
                    if (tab == selectedTab) android.R.color.black else R.color.gray))
                // 设置文字大小
                tab.textSize = if (tab == selectedTab) 16f else 14f
                // 设置下划线
                tab.setUnderlineVisible(tab == selectedTab)
            }
        }
    }