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

前端 未结 11 1139
太阳男子
太阳男子 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:48

    You can create an xml bitmap and use it as background for the view. To prevent stretching you can specify android:gravity attribute.

    for example:

    
    
    
    

    There are a lot of options you can use to customize the rendering of the image

    http://developer.android.com/guide/topics/resources/drawable-resource.html#Bitmap

提交回复
热议问题