BottomNavigationView设置文字和字体大小

设置图片大小

private fun adjustNavigationIcoSize(navigation: BottomNavigationView) {
        val menuView: BottomNavigationMenuView =
            navigation.getChildAt(0) as BottomNavigationMenuView
        for (i in 0 until menuView.getChildCount()) {
            val iconView: View =
                menuView.getChildAt(i).findViewById(R.id.icon)
            val layoutParams: ViewGroup.LayoutParams = iconView.layoutParams
            val displayMetrics: DisplayMetrics = resources.displayMetrics
            layoutParams.height =
                TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20F, displayMetrics).roundToInt()
            layoutParams.width =
                TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20F, displayMetrics).roundToInt()
            iconView.layoutParams = layoutParams
        }
    }

设置文字大小

    

    //在xml指定theme属性
      >

你可能感兴趣的:(BottomNavigationView设置文字和字体大小)