我想要构建如下所示的布局:
在约束布局中,有一个像横幅一样的图像视图,然后是一个卡片,该卡片与横幅的底部边缘中心对齐,接着是另一个图像视图,该图像视图与卡片的顶部边缘中心对齐。我遇到的问题是第二个图像视图(绿色的)在与卡片对齐时会进入背景而不是保持在前景。
以下是XML代码:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
android:paddingBottom="@dimen/padding_10">
<ImageView
android:id="@+id/imageView_jobBackdrop_jobDetails"
android:layout_width="match_parent"
android:layout_height="175dp"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/backdrop_job_details"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_collapseMode="parallax"/>
<ImageView
android:id="@+id/imageView_companyLogo_jobDetails"
android:layout_width="75dp"
android:layout_height="75dp"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
app:layout_constraintBottom_toTopOf="@+id/cardView_jobHeader_jobDetails"
app:layout_constraintEnd_toEndOf="@id/cardView_jobHeader_jobDetails"
app:layout_constraintStart_toStartOf="@id/cardView_jobHeader_jobDetails"
app:layout_constraintTop_toTopOf="@+id/cardView_jobHeader_jobDetails" />
<android.support.v7.widget.CardView
android:id="@+id/cardView_jobHeader_jobDetails"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView_jobBackdrop_jobDetails"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView_jobBackdrop_jobDetails"
app:layout_constraintVertical_bias="0.5">
<android.support.constraint.ConstraintLayout
android:id="@+id/parent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView_jobTitle_jobDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:gravity="center"
android:text="Fresher Software Developer Job. Urgent Openning. Angular Js, HTML, JavaScript, CSS"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
ViewCompat.setElevation(imageview,5);
。 - Raghunandan