marioc
marioc

Reputation: 41

getColor(int id) deprecated

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

Answers (2)

Nikhil S Marathe
Nikhil S Marathe

Reputation: 781

Just use 2 Steps below.

  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
    

Upvotes: 0

FalcoVerhagen
FalcoVerhagen

Reputation: 164

Use ContextCompat.getColor(context, R.color.color_name) As this answer shows: getResources().getColor() is deprecated

Upvotes: 7

Related Questions