カスタムビューの高さを親ビューと同じに設定しようとしています。ConstraintLayout、layout_heightでは0dpですが、ビューは左端に移動しますか?
次のレイアウトでは、カスタムビューの高さを親に正確に設定しています(これはOnMeasureの呼び出しを記録しています)。しかし、制約レイアウトはビューを正しく配置することができません。 layout_heightが0dpに設定されるとすぐに、ビューは左に移動します(Androidスタジオデザイナーを含む)。
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
<View
android:background="#ff0000"
app:layout_constraintRight_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="50dp"
android:layout_height="10dp"
/>
</android.support.constraint.ConstraintLayout>
私が表示されますビューを10dpするために、この高さを設定した場合。
ContraintLayoutは、そのプロパティの1つに0dpが含まれているため、ビューを隠しているようです。これはどのように可能ですか?
docでは、代わりにMATCH_CONSTRAINTに切り替える必要があることが説明されています。
私は間違っていますか?
これはapp:layout_constraintRight_toLeftに設定されていますか?おそらくapp:layout_constraintRight_toRightOf – MidasLefko
を参照してください。 –
答えとして追加して投票できます:) BenPはポイントを取得しようとしています:D – Softlion