0
자신 만의 사용자 정의보기를 만들려고하고 있는데, 나는 onMeasure
이 어떤 값으로 설정되어 있는지를 보여줍니다. 사용자 정의보기 안드로이드 onMeasure 방법은 레이아웃에 설정된 값을 두 배로 표시합니다.
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
int parentHeight = MeasureSpec.getSize(heightMeasureSpec);//shows 200
this.setMeasuredDimension(parentWidth, parentHeight);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
나는 parentHeight 또는 parentWidth 로그인
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.customview.PercentageCircle
android:layout_width="match_parent"
android:layout_height="100dp"
custom:currentValue="0"
custom:maxValue="100"
custom:thickNess="80"
custom:fillBackgroundColor="@color/light_gray"
custom:fillColor="@color/red"
/>
, 나는 두 번 지정된 value.I 얻을 그것의 원인을 이해할 수 없습니다입니다.
당신은'android : layout_width = "match_parent"'를 어떻게 두배로 늘릴 수 있습니까? – pskink
dp에서 100dp를 설정하면 픽셀 값이 표시됩니다. –
예 (match_parent 및 wrap_content는 두 배가됩니다). –