Same-named attributes in attrs.xml for custom view

前端 未结 5 904
夕颜
夕颜 2020-12-04 09:50

I\'m writing a few custom views which share some same-named attributes. In their respective section in attrs.xml I\'d lik

5条回答
  •  一生所求
    2020-12-04 10:18

    I am posting this answer as the above-posted solution didn't work out for me in Android Studio. I need to share my custom attributes among my custom views so I tried the above solution in Android Studio but had no luck. So I experiment and go a way to do it. Hope it might help someone looking for the same problem.

      
        
        
         
             
             
         
    
         
         
        
            
            
            
        
    
    
        
        
        
            
            
            
            ...
        
    
    

    This works for me completely. We need to make a Parent styleable and then we need to inherit that parent styleable. For example, as I have done above : Parent styleable name MyView and inherited this to my other styleable like MyView1 and MyView2 respectively.

提交回复
热议问题