I have a pretty simple layout: A ConstraintLayout, which fills the entire screen, with one large one CardViewthat has at the top ImageView, half on CardViewand half above it (actually not half, but you understand the point).
However, there are two problems: it’s ImageViewlocated to the left of the parent, and I don’t know how to make it horizontally in the center - all I can find on Google are chains for several elements, but I just want one in the center.
The layout editor works very poorly for me. My first complaint is that I seem to be unable to create restrictions for the parent. Then I tried to center ImageViewhorizontally in parent mode by clicking the Center in Parent button. It increases the width CardView, no effect on ImageView.
While I'm in, how could I z-order ImageViewon top CardView?
Here's the layout:
<?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" />
Thank!
source
share