在XML上挣扎。我想在底部显示。很难实施。
这是我想要的布局
android - 如何在CardView底部显示ImageView-LMLPHP
这是我到目前为止所做的努力。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:id="@+id/card"
        android:orientation="vertical">
        <LinearLayout
            android:layout_margin="10dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
        <TextView
            android:padding="5dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="This is Title"
            android:textSize="24sp"
            android:textColor="#000"/>
        <TextView
            android:padding="5dp"
            android:layout_marginTop="10dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="#c5c5c5"
            android:text="This is content.This is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is content"/>
        </LinearLayout>
    </android.support.v7.widget.CardView>

    <com.softoven.ultron.util.RoundedImageView
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:src="@drawable/avatar"
        android:paddingTop="20dp"
        android:layout_gravity="bottom|center_horizontal"/>
</FrameLayout>

最佳答案

这应该对你有用:
1)以RelativeLayout为根视图:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/container">

        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:id="@+id/card"
            android:orientation="vertical">
            <LinearLayout
                android:layout_margin="10dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
                <TextView
                    android:padding="5dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="This is Title"
                    android:textSize="24sp"
                    android:textColor="#000"/>
                <TextView
                    android:padding="5dp"
                    android:layout_marginTop="10dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textColor="#c5c5c5"
                    android:text="This is content.This is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is content"/>
            </LinearLayout>
        </android.support.v7.widget.CardView>
    </LinearLayout>

    <com.softoven.ultron.util.RoundedImageView
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:src="@drawable/avatar"
        android:paddingTop="20dp"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="-40dp"
        android:layout_below="@+id/container" />

</RelativeLayout>

2)以LinearLayout为根视图:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical">

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/container">

                <android.support.v7.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="300dp"
                    android:id="@+id/card"
                    android:orientation="vertical">
                    <LinearLayout
                        android:layout_margin="10dp"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical">
                        <TextView
                            android:padding="5dp"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="This is Title"
                            android:textSize="24sp"
                            android:textColor="#000"/>
                        <TextView
                            android:padding="5dp"
                            android:layout_marginTop="10dp"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:textColor="#c5c5c5"
                            android:text="This is content.This is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is contentThis is content"/>
                    </LinearLayout>
                </android.support.v7.widget.CardView>
            </LinearLayout>

            <com.softoven.ultron.util.RoundedImageView
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:src="@drawable/avatar"
                android:paddingTop="20dp"
                android:layout_marginTop="-40dp"
                android:layout_gravity="center_horizontal" />

</LinearLayout>

10-02 23:18