简体   繁体   English

如何为 BottomNavigationView 设置颜色?

[英]How to set color for BottomNavigationView?

I need to use android:background="?android:attr/windowBackground", but so that the day and night versions have different values.我需要使用 android:background="?android:attr/windowBackground",但白天和夜晚的版本具有不同的值。 How can I do this?我怎样才能做到这一点? Is it possible to do this with using colors.xml and themes.xml是否可以使用 colors.xml 和 themes.xml 来做到这一点

First of all define night-value folder and night theme in appropriate resource directory.首先在合适的资源目录下定义night-value文件夹和night theme

res/values-night/themes.xml res/values-night/themes.xml

Override android:windowBackground like this:像这样覆盖android:windowBackground

  <style name="LaunchTheme" parent="AppTheme">
        <item name="android:windowBackground">@drawable/screen_night</item>
    </style>

Then you can customize your screen like this:然后你可以像这样自定义你的屏幕:

res/drawable/screen_night.xml res/drawable/screen_night.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <color android:color="@color/white"/>
</item>
<item>
    <bitmap
       android:gravity="center"
       android:src="@drawable/any_logo"
       android:tileMode="disabled"/>
</item>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 bottomNavigationView 中的 selectedItem 设置为空? - How to set selectedItem in bottomNavigationView to nothing? 如何在Android上的BottomNavigationView中设置填充项 - How to set fill items in BottomNavigationView on Android 如何在BottomNavigationView中的项目上设置长按侦听器? - How to set long click listener on items in BottomNavigationView? Android/Java:如何以编程方式更改 BottomNavigationView 中 Drawable 的颜色(初始化时没有颜色选择)? - Android/Java: How to change programmatically the color of a Drawable in a BottomNavigationView (with no color selection at initialization)? BottomNavigationView设置为不可点击 - BottomNavigationView set to non-clickable 如何使用 BottomNavigationView 隐藏 TabLayout - How to hide a TabLayout with BottomNavigationView 如何结合 BottomNavigationView 和 ViewPager? - How to combine BottomNavigationView and ViewPager? 如何在 Android Studio 中使用 Activity 而不是 Fragment 更改 BottomNavigationView 中选定图标的颜色? - How do I change the color of the selected icon in BottomNavigationView using Activity instead of Fragment in Android Studio? 如何显示“ BottomNavigationView”菜单图标的图像,因为它仅显示图像的设计,即结构…? - How to set an image for menu icon for “BottomNavigationView”, as it's displaying only image's design i.e. structure…? 如何使用BottomNavigationView在视图之间切换? - How to switch between views with BottomNavigationView?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM