Tuesday, December 31, 2013

[android-developers] Re: LinearLayout as child of ScrollView and View weight's are being ignored

Weights only make sense when the container of the LinearLayout is constraining the height of it.  With its height constrained, LL is then forced to impose heights on all of its children.  It will use weights to do this if you specify them.

When the container of a LL is a ScrollView, the SV doesn't impose a constraint on the height of the LL, which means the LL doesn't impose a height on its children.  It lets them all be as tall as they want.  The SV will then allow the user to scroll to see the entire contents of the LL if it overflows the ScrollView's height.

If you want everything to be constrained to fit on the screen, don't use a ScrollView.  If you want to allow scrolling, then accept that the LL will not impose a height on its children.  If you want to constrain the height of just one child in a LL, then give it an explicit height measurement in dp to override its natural height measurement.

Doug

On Monday, December 30, 2013 2:39:16 PM UTC-8, stanlick wrote:
I have a LinearLayout with three views on it TextView, ImageView and TextView.  The image was pushing the third TextView off the bottom of the screen, so I added weight to the three views.  Now when I place this LinearLayout on a ScrollView, the weights are being ignored!  Is there a way to constrain the size of an image without hardcoding pixels?  I have tried every android:scaleType available and nothing works quite right.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate