Android - How can I create a selector for Layouts (like an ImageButton selector)

前端 未结 2 1145
清歌不尽
清歌不尽 2021-01-15 03:28

I have an ImageButton and a LinearLayout wrapping that button, like this:



        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-15 04:15

    Set the selector to your LinearLayout and add android:descendantFocusability="blocksDescendants" to it.

    In selector, replace all button backgrounds with layout backgrounds.

    
    
        
    
    

    selector layout_bg_selector.xml :

    
    
          
          
          
    
    

提交回复
热议问题