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

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

    Use draw9patch... included within Android Studio's SDK tools. You can define the stretchable areas of your image. Important parts are constrained and the image doesn't look all warped. A good demo on dra9patch is HERE

    Use draw9patch to change your existing splash.png into new_splash.9.png, drag new_splash.9.png into the drawable-hdpi project folder ensure the AndroidManifest and styles.xml are proper as below:

    AndroidManifest.xml:

    
    

    styles.xml:

    
    

提交回复
热议问题