Snippet to determine a size of control in Android

It is a common task to get a control size. You may need it to create image assets to customize that control.

First we get a control object, for example ToggleButton. Then we get a pixel density of the device. After that we can convert px units to dp units.

Leave a Reply

Your email address will not be published. Required fields are marked *