Hard-coding button's width in dimension units
I've got the hard-coded layout, consisting of Button
s, and need to enlarge some of them. I found Button
's method setWidth(int value)
, accepting width in pixels, but I need to set value in dp
. So开发者_如何学编程, how can I set dp
value in program code?
TypedValue
lets you do unit conversions - applyDimension (int unit, float value, DisplayMetrics metrics)
精彩评论