mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
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
|
||||
}
|
||||
}
|
42
app/src/main/java/io/legado/app/utils/NavigationViewUtils.kt
Normal file
42
app/src/main/java/io/legado/app/utils/NavigationViewUtils.kt
Normal file
@ -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
Block a user