Reputation: 41
I solved it like this, do you think it is correct?
getColor(int id, Theme theme);
getColor(R.color.green, getContext().getTheme());
Where "green" is in res/colors.xml
:
<color name="green">#FF00FF00</color>
Upvotes: 4
Views: 4049
Reputation: 781
Just use 2 Steps below.
Import this dependecy in Activity
-> import android.graphics.Color
For Statusbar write the code in the onCreate() method.
-> // Set Background Transparent of Status bar
window.statusBarColor = Color.TRANSPARENT
For Bottom button Navigationbar write the code in the onCreate() method.
-> // Set Background Transparent of bottomNavigation
window.navigationBarColor = Color.TRANSPARENT
Upvotes: 0
Reputation: 164
Use ContextCompat.getColor(context, R.color.color_name)
As this answer shows: getResources().getColor() is deprecated
Upvotes: 7