私はむしろ単純なレイアウトを持っています実際には半分ではありませんが、あなたはポイントを得る)。センター固定サイズのImageViewの
しかし、ImageView
は親の左側に付いていますが、私はそれを水平にセンタリングする方法はわかりません - Googleで見つけることができるのは、複数の要素のチェーンですが、 。
レイアウトエディタは私にとって非常に悪いです。私の最初の苦情は、私が親に制約を作成することができないように見えるということです。次に、親の中心にあるボタンを押して、ImageView
を親の中央に配置してみました。これにより、CardView
の幅が増加し、ImageView
にはまったく影響しません。
CardView
の上にImageView
をzオーダーするにはどうすればよいですか?ここで
レイアウト:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark">
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="32dp"
android:layout_marginEnd="32dp"
android:layout_marginStart="32dp"
android:layout_marginTop="160dp"
app:cardCornerRadius="12dp"
app:cardElevation="32dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent">
</android.support.v7.widget.CardView>
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginTop="40dp"
android:scaleType="centerCrop"
android:src="@drawable/re_zero"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
ありがとう! docsによると
素晴らしいソリューション!これを理解することにいくつか問題があった – hcpl