How to implement an android:background that doesn't stretch?

前端 未结 11 1179
太阳男子
太阳男子 2020-11-28 02:51

I found this great thread describing how to \"eat the cake and have it too\", i.e. use image for a Button instead of ImageButton (which doesn\'t al

11条回答
  •  孤街浪徒
    2020-11-28 03:44

    I am using an ImageView in an RelativeLayout that overlays with my normal layout. No code required. It sizes the image to the full height of the screen (or any other layout you use) and then crops the picture left and right to fit the width. In my case, if the user turns the screen, the picture may be a tiny bit too small. Therefore I use match_parent, which will make the image stretch in width if too small.

    
    
        
    
        
        
    
    
    

提交回复
热议问题