how to get background color from current theme programmatically

前端 未结 3 1060
醉酒成梦
醉酒成梦 2020-12-02 17:02

I tried something like this, but i stuck:

TypedValue typedValue = new TypedValue(); 
if (this.parentActivity.getTheme().resolveAttribute(android.R.attr.windo         


        
3条回答
  •  情深已故
    2020-12-02 17:57

    You can get the resources of your Theme by using :

    TypedArray a = getTheme().obtainStyledAttributes(R.style.ThemeName, new int[] {R.attr.attribute_name});     
    int attributeResourceId = a.getResourceId(0, 0);
    

提交回复
热议问题