Android LinearLayout Selector background color

后端 未结 3 1950
攒了一身酷
攒了一身酷 2021-02-13 09:37

Hi I\'m trying to make my linear layout work like button. I mean I\'m trying to change its background color when the state is changed. I used selector to solve it, but it didn\'

3条回答
  •  礼貌的吻别
    2021-02-13 10:02

    I am using a linear layout as a button however, I do not have anything assigned as clickable or not and it seems to work just fine. I have set up a style for my standard button and I just assign that style to the linear layout like I would any other button.

    The linearlayout as a button:

    
    
        
    
        
    
    

    My style definition for the button:

    
    

    My @drawable/btn_stan_sel file:

    
    
    
        
        
    
        
        
    
        
        
    
        
        
    
    
    

    My drawable file repeated for each state just with different colors for each state:

    
    
    
        
    
        
    
        
    
    
    

提交回复
热议问题