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
}