pull/1391/head
parent
c2bc2ae34d
commit
f0cf410bd8
@ -1,53 +0,0 @@ |
||||
package io.legado.app.lib.theme |
||||
|
||||
import android.content.res.ColorStateList |
||||
import androidx.annotation.ColorInt |
||||
import com.google.android.material.internal.NavigationMenuView |
||||
import com.google.android.material.navigation.NavigationView |
||||
|
||||
/** |
||||
* @author Karim Abou Zeid (kabouzeid) |
||||
*/ |
||||
@Suppress("unused") |
||||
object NavigationViewUtils { |
||||
|
||||
fun setItemIconColors( |
||||
navigationView: NavigationView, |
||||
@ColorInt normalColor: Int, |
||||
@ColorInt selectedColor: Int |
||||
) { |
||||
val iconSl = ColorStateList( |
||||
arrayOf( |
||||
intArrayOf(-android.R.attr.state_checked), |
||||
intArrayOf(android.R.attr.state_checked) |
||||
), |
||||
intArrayOf(normalColor, selectedColor) |
||||
) |
||||
navigationView.itemIconTintList = iconSl |
||||
} |
||||
|
||||
fun setItemTextColors( |
||||
navigationView: NavigationView, |
||||
@ColorInt normalColor: Int, |
||||
@ColorInt selectedColor: Int |
||||
) { |
||||
val textSl = ColorStateList( |
||||
arrayOf( |
||||
intArrayOf(-android.R.attr.state_checked), |
||||
intArrayOf(android.R.attr.state_checked) |
||||
), |
||||
intArrayOf(normalColor, selectedColor) |
||||
) |
||||
navigationView.itemTextColor = textSl |
||||
} |
||||
|
||||
/** |
||||
* 去掉navigationView的滚动条 |
||||
* @param navigationView NavigationView |
||||
*/ |
||||
fun disableScrollbar(navigationView: NavigationView?) { |
||||
navigationView ?: return |
||||
val navigationMenuView = navigationView.getChildAt(0) as? NavigationMenuView |
||||
navigationMenuView?.isVerticalScrollBarEnabled = false |
||||
} |
||||
} |
@ -0,0 +1,42 @@ |
||||
@file:Suppress("unused") |
||||
|
||||
package io.legado.app.utils |
||||
|
||||
import android.content.res.ColorStateList |
||||
import androidx.annotation.ColorInt |
||||
import com.google.android.material.internal.NavigationMenuView |
||||
import com.google.android.material.navigation.NavigationView |
||||
|
||||
fun NavigationView.setItemIconColors( |
||||
@ColorInt normalColor: Int, |
||||
@ColorInt selectedColor: Int |
||||
) { |
||||
val iconSl = ColorStateList( |
||||
arrayOf( |
||||
intArrayOf(-android.R.attr.state_checked), |
||||
intArrayOf(android.R.attr.state_checked) |
||||
), |
||||
intArrayOf(normalColor, selectedColor) |
||||
) |
||||
itemIconTintList = iconSl |
||||
} |
||||
|
||||
fun NavigationView.setItemTextColors( |
||||
@ColorInt normalColor: Int, |
||||
@ColorInt selectedColor: Int |
||||
) { |
||||
val textSl = ColorStateList( |
||||
arrayOf( |
||||
intArrayOf(-android.R.attr.state_checked), |
||||
intArrayOf(android.R.attr.state_checked) |
||||
), |
||||
intArrayOf(normalColor, selectedColor) |
||||
) |
||||
itemTextColor = textSl |
||||
} |
||||
|
||||
fun NavigationView.disableScrollbar() { |
||||
val navigationMenuView = getChildAt(0) as? NavigationMenuView |
||||
navigationMenuView?.isVerticalScrollBarEnabled = false |
||||
} |
||||
|
Loading…
Reference in new issue