|
@@ -4,6 +4,7 @@ package jx.cn.escort.ui.activity
|
|
import android.content.Context
|
|
import android.content.Context
|
|
import android.content.SharedPreferences
|
|
import android.content.SharedPreferences
|
|
import android.content.res.ColorStateList
|
|
import android.content.res.ColorStateList
|
|
|
|
+import android.graphics.Color
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
import android.view.MenuItem
|
|
import android.view.MenuItem
|
|
import android.view.View
|
|
import android.view.View
|
|
@@ -12,9 +13,11 @@ import android.widget.Toast
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import androidx.appcompat.view.menu.MenuItemImpl
|
|
import androidx.appcompat.view.menu.MenuItemImpl
|
|
import androidx.appcompat.widget.AppCompatTextView
|
|
import androidx.appcompat.widget.AppCompatTextView
|
|
|
|
+import androidx.core.view.children
|
|
import androidx.fragment.app.Fragment
|
|
import androidx.fragment.app.Fragment
|
|
import androidx.fragment.app.FragmentContainerView
|
|
import androidx.fragment.app.FragmentContainerView
|
|
import androidx.fragment.app.FragmentTransaction
|
|
import androidx.fragment.app.FragmentTransaction
|
|
|
|
+import com.google.android.material.bottomnavigation.BottomNavigationItemView
|
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
import com.google.android.material.navigation.NavigationBarView
|
|
import com.google.android.material.navigation.NavigationBarView
|
|
@@ -70,10 +73,27 @@ class MainActivity : AppCompatActivity(), KoinComponent {
|
|
|
|
|
|
var bottomNav= findViewById<BottomNavigationView>(R.id.bottom_nav)
|
|
var bottomNav= findViewById<BottomNavigationView>(R.id.bottom_nav)
|
|
|
|
|
|
-// var colorStateList = ColorStateList(
|
|
|
|
-// IntArray()
|
|
|
|
-//
|
|
|
|
-// )
|
|
|
|
|
|
+ bottomNav.setSelectedItemId(R.id.index)
|
|
|
|
+
|
|
|
|
+ var ckColor=Color.parseColor("#3ADD5C")
|
|
|
|
+
|
|
|
|
+ var color=Color.parseColor("#5e5656")
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 设置图标颜色
|
|
|
|
+ val colorStateList = ColorStateList(
|
|
|
|
+ arrayOf(
|
|
|
|
+ intArrayOf(android.R.attr.state_checked),
|
|
|
|
+ intArrayOf(-android.R.attr.state_checked)
|
|
|
|
+ ),
|
|
|
|
+ intArrayOf(ckColor,color) // 这里设置为你想要的颜色
|
|
|
|
+ )
|
|
|
|
+ bottomNav.itemIconTintList = colorStateList
|
|
|
|
+
|
|
|
|
+ // 设置文字颜色
|
|
|
|
+ bottomNav.itemTextColor = colorStateList
|
|
|
|
+ bottomNav.isItemActiveIndicatorEnabled=false
|
|
|
|
+ bottomNav.setItemBackgroundResource(R.drawable.nav_item_bg)
|
|
|
|
|
|
|
|
|
|
bottomNav.setOnItemSelectedListener(object: NavigationBarView.OnItemSelectedListener {
|
|
bottomNav.setOnItemSelectedListener(object: NavigationBarView.OnItemSelectedListener {
|
|
@@ -83,10 +103,13 @@ class MainActivity : AppCompatActivity(), KoinComponent {
|
|
|
|
|
|
when(id){
|
|
when(id){
|
|
jx.cn.escort.R.id.index-> {
|
|
jx.cn.escort.R.id.index-> {
|
|
- var indexMenu=bottomNav.menu.findItem(R.id.index);
|
|
|
|
- indexMenu.setIcon(R.drawable.ic_nav_index_ck);
|
|
|
|
- var fragmentContainerView=findViewById<FragmentContainerView>(R.id.nav_content)
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var indexMenu=bottomNav.menu.findItem(R.id.index);
|
|
|
|
+
|
|
|
|
+ indexMenu.menuInfo
|
|
|
|
+ var fragmentContainerView=findViewById<FragmentContainerView>(R.id.nav_content)
|
|
// var density=resources.displayMetrics.density
|
|
// var density=resources.displayMetrics.density
|
|
// fragmentContainerView.setPadding(
|
|
// fragmentContainerView.setPadding(
|
|
// fragmentContainerView.paddingLeft,
|
|
// fragmentContainerView.paddingLeft,
|
|
@@ -98,11 +121,9 @@ class MainActivity : AppCompatActivity(), KoinComponent {
|
|
switchFragment(BaseNavFragment(R.layout.fragment_index, context = baseContext),item)
|
|
switchFragment(BaseNavFragment(R.layout.fragment_index, context = baseContext),item)
|
|
}
|
|
}
|
|
R.id.tasks->{
|
|
R.id.tasks->{
|
|
- bottomNav.menu.findItem(R.id.tasks).setIcon(R.drawable.ic_nav_tasks_ck);
|
|
|
|
switchFragment(BaseNavFragment(R.layout.fragment_tasks, context = baseContext),item)
|
|
switchFragment(BaseNavFragment(R.layout.fragment_tasks, context = baseContext),item)
|
|
}
|
|
}
|
|
R.id.mine->{
|
|
R.id.mine->{
|
|
- bottomNav.menu.findItem(R.id.mine).setIcon(R.drawable.ic_nav_mine_ck);
|
|
|
|
switchFragment(BaseNavFragment(R.layout.fragment_mine,context = baseContext),item)
|
|
switchFragment(BaseNavFragment(R.layout.fragment_mine,context = baseContext),item)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -114,8 +135,8 @@ class MainActivity : AppCompatActivity(), KoinComponent {
|
|
|
|
|
|
})
|
|
})
|
|
|
|
|
|
- bottomNav.setSelectedItemId(R.id.index)
|
|
|
|
- // bottomNav.setItemBackgroundResource(R);
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|