开发者

Android: Change button insets

I have the following button:

http://dl.dropbox.com/u/3564087/button.png

However this image has a blank area on the right side, border and shadow (which doesn't exist on the right side). This means that when I insert some text on the button and set the gravity to center, the text doesn't really gets centered because the area in which i want it to be centered isn't the total area of the image.

My question is, can I set an inset Rect (the same way as you can do in iOS), in which I want to display the开发者_运维百科 text? Or do I need to create a separate TextView in front of the Button?


You can do it by creating a 9 patch image. It won't only allow to define a rect where the text will go, but also will allow your button to stretch to any size screen and resolution.


Although I can do this using 9-patch, I found that it is simpler to do it using the "padding" property of the Button view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜