Android – how to display ImageView at the bottom of cardview
•
Android
Suffering from XML. I want to display roundedcornerimageview at the bottom of cardview. It's difficult to implement it
This is what I want the layout to look like
This is the XML. XML I've tried so far
<?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>
resolvent:
This should suit you:
1) Take relativelayout as the root view:
<?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) Use LinearLayout as the root view:
<?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>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码