[android-developers] Re: LinearLayout as child of ScrollView and View weight's are being ignored
Thanks Doug
-- I've read the article several times from top to bottom. I subsequently turn to the editor and start practicing, only to find it does not work quite the way the article suggests. I believe the screen design/layout is perhaps the most elusive aspect of Android and with no strong visual tooling, might just remain that way for awhile longer. I once coded a sizable desktop Swing JFC application using GridBagLayout with all its weights, glue, shims, spacers and the rest. This was to allow it to work on different screen sizes and resolutions. In a strange way, I feel Deja Vu all over again!
Peace,
Scott
On Thursday, January 2, 2014 2:41:19 AM UTC-6, Doug wrote:
On Thursday, January 2, 2014 2:41:19 AM UTC-6, Doug wrote:
It sounds like you maybe want to use different layouts for different screen types rather than depending on sizes of images for different pixel densities. I recommend you read and understand the majority of this document to fully understand how Android deals with different screens and what kind of options you have:
http://developer.android.com/guide/practices/screens_ support.html
Doug
On Wednesday, January 1, 2014 7:04:05 AM UTC-8, stanlick wrote:Thanks Doug!This is what I was thinking, but always like a second opinion. I think I'm going to study the the various image size folders drawable-ldpi, drawable-mdpi, etc., and include form-factor appropriate images. It's a shame, Android could not take the highest resolution image and scale it down to fit the other form factors. Heck maybe it does with the scaleType and I'm just confused by the ScrollView overriding my layout decisions. The smallest device, as I see it, is the 240x320 (is that a watch) and it certainly wants smaller pics than my 90" TV!Peace,Scott
On Tuesday, December 31, 2013 1:22:03 PM UTC-6, Doug wrote: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