复选框的默认大小是多少



checkbox具有固定的大小。我想知道checkbox默认的浸渍大小。或者我怎样才能获得默认的浸渍尺寸。

您可以重写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 
}

最新更新