0
私は独自のカスタムビューを作成しようとしていますが、onMeasure
は2つの値を示しています。 カスタムビューandroid onMeasureメソッドは、レイアウトに設定された値の2倍を表示します。
@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が2倍になります。 –