[问题] 关于ImageView被CardView覆蓋

楼主: lee16818 (afkk)   2020-08-11 03:12:17
各位先进晚安,小鲁最近在实作类似Between回忆录的功能
小鲁原本是将ImageView放进CardView中实现的,
但后来发现这与Between的回忆录不同(个人认为Between的会比较好看)
而我与Between的不同在于,他的图片其实会跑出CardView之外,
因次我试着将ImageView放到外层的Layout中,但却发现ImageView会被CardView所覆蓋
因此想上来请教,是否有方法或是关键字查询能让小鲁知道如何将ImageVIew显示到最上

麻烦各位大德伸出援手了!
(下图为本人实作)
https://i.imgur.com/uFYyWEA.jpg
(下图为Between样板)
https://i.imgur.com/cqwaOPv.jpg
附上XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schem
as
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/c1"
android:layout_width="match_parent"
android:layout_height="325dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="275dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/Card">
<ImageView
android:id="@+id/Picture"
android:layout_width="match_parent"
android:layout_height="275dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/baseline_insert_photo_white_18dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.cardview.widget.CardView
android:id="@+id/Card"
android:layout_width="375dp"
android:layout_height="300dp"
app:cardElevation="30px"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_gravity="bottom"
android:layout_marginLeft="350dp"
android:alpha="0.5"
android:background="@drawable/baseline_more_vert_black_18dp" />
<TextView
android:id="@+id/textView6"
android:layout_width="92dp"
android:layout_height="34dp"
android:layout_gravity="bottom"
android:alpha="0.2"
android:background="@drawable/lider2"
android:textStyle="italic" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="350dp"
android:layout_height="275dp"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:layout_marginBottom="30dp">
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
作者: zcbxvsdf (东北一头羊)   2020-08-11 08:44:00
https://link.medium.com/4S6IElPMQ8CardView是ViewGroup, 你要把Imageview包进去当他的子View, 你这样只是覆蓋而已
作者: gcobc12632 (Ted)   2020-08-11 14:02:00
不要把Imageview包在CardView内 然后有两种做法一种是 CardView app:cardElevation="0dp"另一种是 ImageView android:elevation="2dp"大概像这样 https://i.imgur.com/Pdh0bmG.png不知道是不是你要的效果

Links booklink

Contact Us: admin [ a t ] ucptt.com