I am using xamarin android to make a android app in which i am using cardview with recycler view.
Problem
Image height is exceeding the wrap content of the text.
What is Want
I want the image size to be the size covered by text.
What I Have Tried:
I have tried setting image as a background of the linearlayout but it sets the height of the layout itself much greater than shown in images below. i have tried setting this in framelayout but it gives same result as below
Details about the images
numbers are provided with the instance of the card view in
1: image the image source height is increasing the view height
2: this image is setted perfectly because the original image height resolution is low and the image is stretched to view
3: again image height resolution is high so the view is extended by image
4,5 cardview without image
My Code:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/cardView"
app:cardBackgroundColor="@android:color/transparent">
<ImageView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:id="@+id/cardImage"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/templateLayout"
>
<TextView
android:text="Title:"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:id="@+id/listTitle"/>
<TextView
android:text="Start Time:"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:id="@+id/listSTime"/>
<TextView
android:text="End Time:"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:id="@+id/listFTime"/>
<TextView
android:text="Description:"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:id="@+id/listDescription"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
Images: