Does LinearLayout have a max height?
The "implicit" max height of the layout is the height of its parent. Since you're using wrap_content
on both layouts, that means the parent is effectively the screen area, minus whatever other views you're using (such as the TextView
). Unless you place it in a scrolling container, such as a ScrollView
, it won't ever exceed the size of the screen.
The reason your ImageView
isn't showing up "full width and huge" when you remove the crop is because the default scaleType
for an ImageView
is fitCenter
. This particular view is bounded by the layout's width, so it shrinks the image while maintaining aspect ratio.
bungleofsketches
Updated on June 04, 2022Comments
-
bungleofsketches almost 2 years
I have a vertical linearlayout that won't stretch beyond a certain limit.
This is the layout with centerCrop in the imageview http://tinypic.com/r/20nm6s/5
This is the layout with no crop set (so it should be full width and huge) http://tinypic.com/r/vzk7kw/5
So my thought is that there is some implicit max height that I'm not seeing in my layout but I can't see where it is, can you spot my error?
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="@drawable/dropshadow" > <TextView android:id="@+id/heading" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" /> <ImageView android:id="@+id/featuredimage" android:layout_width="fill_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:maxHeight="1000dp" android:scaleType="centerCrop" android:layout_marginTop="10dp" android:layout_marginBottom="10dp" /> </LinearLayout> </RelativeLayout>
-
David over 10 yearsAlso, the LinearLayout being in the RelativeLayout for what you have is wasteful. Place the XMLNS tag on the LinearLayout and remove the RelativeLayout.
-
Geobits over 10 yearsYou could also remove the Linear and use Relative with appropriate attributes, but Linear would be simpler. Either way, you definitely don't need both of them.