I have this ImageView I want cropped to occupy no more than 1/3 the screen size. I have used the following layout using layout_height="0dp" and layout_weight where needed but the ImageView keeps taking more height than it should. If I replace the ScrollView with LinearLayout everything falls into place as it should. My guess is this is because the ScrollView has unlimited height... How can I still force the ScrollView to honor the real layout height of its parent and achieve what I want.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ImageView
android:id="@+id/imageview"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:src="@drawable/image"
android:scaleType="centerCrop"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="vertical"
>
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginLeft="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:text="Text1"
/>
<TextView
android:id="@+id/textview2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:singleLine="true"
android:ellipsize="end"
android:marqueeRepeatLimit="marquee_forever"
android:text="Text2"
/>
<TextView
android:id="@+id/textview3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:singleLine="true"
android:ellipsize="end"
android:marqueeRepeatLimit="marquee_forever"
android:text="Text3"
/>
<TextView
android:id="@+id/textview4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:singleLine="false"
android:text="Text4"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Here's how it looks like: