getColor(int id) 已经被弃用。

4
我是这样解决的,你认为是否正确?
getColor(int id, Theme theme);
getColor(R.color.green, getContext().getTheme());

当 "green" 在 res/colors.xml 中时:

color name="green">#FF00FF00</color>

这个解决方案很好,假设你将主题切换为暗模式,并且在暗主题样式中将绿色定义为#fff,它将自动切换。 - undefined
2个回答

6

0
只需按照以下2个步骤操作。
1. Import this dependecy in Activity
           ->  import android.graphics.Color

2. For Statusbar write the code in the onCreate() method.
           ->   // Set Background Transparent of Status bar
                window.statusBarColor = Color.TRANSPARENT
3. For Bottom button Navigationbar write the code in the onCreate() method.
           ->   // Set Background Transparent of bottomNavigation
                window.navigationBarColor = Color.TRANSPARENT

☻♥ 完成保留代码。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接