LinearLayout View Tutorial, weight behavior

by maximus-dev » Fri, 13 Nov 2009 07:22:41 GMT


Sponsored Links
 Hi Everyone...

Very short background... I'm currently a C developer (not C++
unfortunately... so no experience with OOP) who writes homebrew for
the nintendo DS. I'm exploring moving away from that platform and
towards the Android.

That said, I'm doing as suggested at the end of the LinearLayout View
tutorial and modifying the weight values to see how it affects the
size of the columns and rows. The structure seemed very simple, so it
seemed obvious that modifying the first weight (the top half) to 2
should give the top section 2/3rds of the screen and the bottom only
1/3rd. Instead... it appeared to be reversed... the upper area had
become the smaller third (this is in the emulator... I do not have
actual hardware yet).

I tested the same idea on the color columns and the more expected
result occured... the columns with greater weight were now wider and
seemed to take up the correct fractional area of the screen.

Any particular reason for this behavior?

Thanks everyone,
Jeremiah

--



LinearLayout View Tutorial, weight behavior

by Indicator Veritatis » Fri, 13 Nov 2009 09:20:27 GMT


 Hi-

The most likely explanation is that you did not modify the weight you
thought you did. The very first occurrence of the layout_weight
attribute is in the outermost LinearLayout, so it applies to the
entire screen, not to the upper half alone (the color bands). To
change the weight only for the latter, you need to change the SECOND
occurrence of the layout_weight attribute.

Of course, that still doesn't explain the reverse behavior you
described, but at least it is a start.

Now concerning your background: it is impressive that you have made
this much progress in Android w/o an OOP background, but you will make
it much easier on yourself if you take the time out to learn at least
the elements of OOP using Java before putting too much effort into
Android. All the Android documentation and tutorials do assume a
fairly high level of familiarity with these elementary facts about
Java.




--


Sponsored Links


LinearLayout View Tutorial, weight behavior

by Indicator Veritatis » Fri, 13 Nov 2009 09:38:41 GMT


 Or so I thought on first reading. But no, I was misled by the small
frame in the tutorial. Now that I have it running in the emulator
myself, I see the exact same thing you saw.

OTOH, the behavior is closer to what is to be expected (based on the
tutorial) if you change from the default only the weight in the green
band, changing from 1 to 2: then the green band is approximately twice
as big as the red and blue, but the yellow falls somewhere in between!

It looks like the layout manager is not perfect.





--



LinearLayout View Tutorial, weight behavior

by maximus-dev » Mon, 16 Nov 2009 12:45:05 GMT


 hanks for taking a look at this. Glad to know I'm not just crazy.
It's not a big deal, I'm not likely to use this particular layout, I
don't think.

Very shortly after this I pulled up the tutorials right on Sun's site
and started reading. It was apparent that although some syntax was
similar that the style is dramatically different. It's quite
fascinating... I'm trying very hard not to make comparisons to C. The
more I read, the more I can see that making comparisons would be a
huge mistake.

Is this the kind of thing I should be reporting somewhere?

On Nov 12, 5:38pm, Indicator Veritatis <mej1...@yahoo.com> wrote:

--



LinearLayout View Tutorial, weight behavior

by maximus-dev » Mon, 16 Nov 2009 12:46:40 GMT


 Trying to reply again... it didn't show up last time.

I actually stopped right after this and started reading the java
tutorial on sun's website. It's very enlightening.

Is this something that should be reported somewhere?






--



Other Threads

1. How to write an appplication that can handle OMA DRM v1.0 content?

I want to write a image application that can display pictures
protected by OMA DRM v1.0.
Who can share me some idea to start the work?

What API/service of Android can help me to show a DRM picture? And
shall I register my application to handle the MIME type of OMA DRM
v1.0 (application/vnd.oma.drm.message & application/
vnd.oma.drm.content)? ...

Many thanks!
Amanda

-- 

2. how to get root access in android emulator

I install the Droidwall(http://code.google.com/p/droidwall/) in the
android emulator .But when I  try to enable the rules I get the
following error message:

"Could not acquire root access. You need a rooted phone to run
DroidWall.
If this phone is already rooted, please make sure DroidWall has
ennough permissions to execute the "su" command.

Does the android emulator  not hava the root access?
If so,how can I get the root access in android emulator?
Thanks!

-- 

3. Progressive Download Support in Android's 2.3

4. problem in pie chart coding

5. Advertise Swap

6. VideoView from resource File

7. Bluetooth in Android