Theme, Styles and Alias nesting not working

后端 未结 1 1088
萌比男神i
萌比男神i 2020-12-20 05:48

I\'m trying to test a way to make themes, but the approach I used isn\'t giving me the expected results. Here my setup:

drawable/dummy.xml



        
1条回答
  •  -上瘾入骨i
    2020-12-20 06:10

    I do not pretend to the correctness of the decision, but it works. I solved the problem by this trick:

    My attrs:

    
    
    

    My themes:

    
    
    

    My var's:

    private TypedArray arrowUpActive, arrowDownActive;
    

    Declaration:

    arrowUpActive = getActivity().getTheme().obtainStyledAttributes(new int[] { R.attr.arrow_up_active });
    arrowDownActive = getActivity().getTheme().obtainStyledAttributes(new int[] { R.attr.arrow_down_active });
    

    And usage:

    imageButton.setImageDrawable(getResources().getDrawable(arrowUpActive.getResourceId(0,1)));
    imageButton.setImageDrawable(getResources().getDrawable(arrowDownActive.getResourceId(0,1)));
    

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