什么是复选框默认大小

时间:2016-05-24 02:33:10

标签: android checkbox size

checkbox具有固定大小。我想知道checkbox默认倾角大小。或者我如何获得默认倾角尺寸。

1 个答案:

答案 0 :(得分:0)

您可以覆盖onWindowFocusChanged方法,在其中可以以编程方式计算CheckBox宽度/高度

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);

     int checkBoxWidthInPx = mCheckBox.getWidth(); // return the width of your checkbox, in pixels.
     int checkBoxHeightInPx = mCheckBox.getHeight();

     // conver px to dp
     int checkBoxWidthInDp = checkBoxWidthInPx / this.getResources().getDisplayMetrics().density
     int checkBoxHeightInDp = checkBoxHeightInPx / this.getResources().getDisplayMetrics().density 
}
相关问题