如何将视图置于 CardView 前面?

3

我有一个设计模式,但不确定如何创建。应该是这样的:

enter image description here

我仍然在努力将图像视图放在卡片视图前面。您对此有什么想法或示例吗?谢谢!

这是我所做的:

<RelativeLayout android:id="@+id/containor"
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin">

<de.hdodenhof.circleimageview.CircleImageView
    android:id="@+id/iv_profile"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_centerHorizontal="true"
    android:layout_marginEnd="5dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_marginStart="5dp"
    android:src="@drawable/soccer_player"
    app:civ_border_color="@color/colorAccent"
    app:civ_border_width="2dp"/>

<android.support.v7.widget.CardView
    android:id="@+id/card"
    android:layout_width="400dp"
    android:layout_height="150dp"
    android:layout_marginTop="10dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/bg_card_review">

        <TextView
            android:id="@+id/tv_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Nije lose"
            android:textColor="@android:color/white"
            android:textSize="16sp"
            android:typeface="sans"/>

    </RelativeLayout>

</android.support.v7.widget.CardView>


2
在帧布局和相对布局中,最后添加的布局位于顶部。因此,只需更改编写它们的顺序即可。如果更改顺序无效,请在问题中提供您的父布局。 - undefined
1
也许这个链接可以帮到你:https://dev59.com/M1sW5IYBdhLWcg3w2aOK - undefined
1个回答

6

你需要为你的ImageView设置更高的elevation(海拔高度)。 例如,尝试以下代码...

ViewCompat.setElevation(findViewById(R.id.iv_profile),yourCardView.getElevation() * 2);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接