开发者

How to change the button fontsize without changing button size (in android)?

开发者 https://www.devze.com 2023-01-01 11:52 出处:网络
I need to have a grid (created by program, not by 开发者_如何转开发xml) of equally sized buttons. They display text in different sizes.

I need to have a grid (created by program, not by 开发者_如何转开发xml) of equally sized buttons. They display text in different sizes. The problem is that when I change the text size to a smaller size, then the button automatically resizes to be smaller than the others.

Thanks,

Note: the grid is created adding TableRows of buttons to a TableLayout. The buttons are created and added to a TableRow

tr.addView(bu, 36, 45);


Adding padding (setPadding()) will expand the button while keeping the font size small. Figuring out how much padding to add, though, is up to you.

0

精彩评论

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