How to get Android system Colors?

后端 未结 3 2150
日久生厌
日久生厌 2021-02-20 08:03

I\'m searching way to get Android system colors - color theme used in device.

Using android:color/ I didn\'t get correct colors. For example: background col

相关标签:
3条回答
  • 2021-02-20 08:26

    Thanks for rekire :)

    Finally I have the answer: Android: How to get background color of Activity in Java?

    TypedArray array = getTheme().obtainStyledAttributes(new int[]{android.R.attr.colorBackground,}); 
    int backgroundcolor = array.getColor(0, 0xFF00FF);
    
    0 讨论(0)
  • 2021-02-20 08:37

    It might just be setting a color filter on whatever the base color of the device is. That may be why you're not getting the base color you were expecting.

    This is just a theory, I haven't verified it yet. Either that, or the base color for the theme you're looking is stored in a slightly different location. That's also a possibility.

    0 讨论(0)
  • 2021-02-20 08:42

    You can get android system color using

    android:textColor="@android:color/black"
    

    And this is working fine

    0 讨论(0)
提交回复
热议问题