how to change background image of button when clicked/focused?

后端 未结 8 1071
旧时难觅i
旧时难觅i 2020-11-30 01:00

I want to change the background image of a button when clicked or focused.

This is my code:

Button tiny = (Button)findViewById(R.id.tiny);
tiny.setOn         


        
8条回答
  •  春和景丽
    2020-11-30 01:30

    You can also create shapes directly inside the item tag, in case you want to add some more details to your view, like this:

    
    
        
            
                
                
            
            
        
        
            
                
                
            
        
        
            
                
                
            
        
    
    

    Beware that Android will cycle through the items from top to bottom, therefore, you must place the item without condition on the bottom of the list (so it acts like a default/fallback).

提交回复
热议问题