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,


LinearLayout View Tutorial, weight behavior

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


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


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 <> 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. LVL question: how the method VerifyLicense in the class ResultListener in class LicenseChecker be called.

Hi all,

I want to make it clear how the VerifyLicense method of the class
ResultListener in class LicenseChecker be called. Is it be called by Android
Market client?

The VerifyLicense code is as below:

        public void verifyLicense(final int responseCode, final String
                final String signature) {
   Runnable() {
                public void run() {
                    Log.i(TAG, "Received response.");
                    // Make sure it hasn't already timed out.
                    if (mChecksInProgress.contains(mValidator)) {
                        mValidator.verify(mPublicKey, responseCode,
signedData, signature);

How the method mValidator.verify can guarantee the response is not faked, by
its three parameters, mPublicKey, signedData, and signature, if the
signature here can be get from SDK API?


2. Android kernel 2.6.32 on OMAP2430 kernel panic: Attempted to kill init Problem

Dear all,
       I wanted to boot my omap 2430 SDP board with Android 2.2 using
kernel 2.6.32. I've done the following to bring the board up.
1) I've downloaded the kernel from the following link.
2) I checkout the tag named "v2.6.32"
3) Configured the kernel for omap2430 using the default configuration
file named "omap_2430sdp_defconfig"
4) Configured again for Android. Please find the attached
configuration file for your reference.
5) My omap2430 board does not have a touchscreen. It only has a LCD
6) The root file system is mounted via NFS.
7) The kernel messages are shown below.

Linux version 2.6.32-00000-v2.6.32-dirty (r...@localhost.localdomain)
(gcc versi
on 4.4.1 (Sourcery G++ Lite 2009q3-67) ) #18 PREEMPT Thu Dec 2
14:50:38 IST 2010
CPU: ARMv6-compatible processor [4107b366] revision 6 (ARMv6TEJ),
CPU: VIPT aliasing data cache, VIPT aliasing instruction cache
Machine: OMAP2430 sdp2430 board
Memory policy: ECC disabled, Data cache writeback

SRAM: Mapped pa 0x40200000 to va 0xe3000000 size: 0x100000
Built 1 zonelists in Zone order, mobility grouping on.  Total pages:
Kernel command line: console=ttyS0,115200n8=noinitrd ip=
nfs rw nfsroot=,nolock
mem=64M v
ideo=omapfb.mode=dvi:240x320 init=/init
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60876KB available (3340K code, 445K data, 116K init, 0K
Hierarchical RCU implementation.
Clocking rate (Crystal/DPLL/MPU): 13.0/660/330 MHz
GPMC revision 3.0
IRQ: Found an INTC at 0xd80fe000 (revision 3.0) with 96 interrupts
Total of 96 interrupts on 1 active controller
OMAP243x GPIO hardware version 2.4
OMAP clockevent source: GPTIMER1 at 13000000 Hz
Console: colour dummy device 80x30
Calibrating delay loop... 329.31 BogoMIPS (lpj=1646592)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
OMAP DMA hardware revision 4.0
bio: create slab <bio-0> at 0
i2c_omap i2c_omap.1: bus 1 rev3.7 at 400 kHz
i2c_omap i2c_omap.2: bus 2 rev3.7 at 2600 kHz
twl4030: PIH (irq 7) chaining IRQs 368..375
twl4030: power (irq 373) chaining IRQs 376..383
Switching to clocksource gp timer
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
VFS: Disk quotas dquot_6.5.2
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
JFFS2 version 2.2. (NAND)  2001-2006 Red Hat, Inc.
msgmni has been set to 119
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
omapfb: configured for panel sdp2430
omapfb omapfb: timeout waiting for FRAME DONE
omapfb: DISPC version 3.0 initialized
Console: switching to colour frame buffer device 30x40
omapfb: Framebuffer initialized. Total vram 155648 planes 1
omapfb: Pixclock 5156 kHz hfreq 18.2 kHz vfreq 54.8 Hz
omap_rng omap_rng: OMAP Random Number Generator ver. 50
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
serial8250.0: ttyS0 at MMIO 0x4806a000 (irq = 72) is a ST16654
console [ttyS0] enabled
serial8250.1: ttyS1 at MMIO 0x4806c000 (irq = 73) is a ST16654
serial8250.2: ttyS2 at MMIO 0x4806e000 (irq = 74) is a ST16654
brd: module loaded
loop: module loaded
omapflash.0: Found 1 x16 devices at 0x0 in 16-bit bank
omapflash.0: Found 1 x16 devices at 0x2000000 in 16-bit bank
 Intel/Sharp Extended Query Table at 0x010A
 Intel/Sharp Extended Query Table at 0x010A
 Intel/Sharp Extended Query Table at 0x010A
 Intel/Sharp Extended Query Table at 0x010A
 Intel/Sharp Extended Query Table at 0x010A
 Intel/Sharp Extended Query Table at 0x010A
Using buffer write method
Using auto-unlock on power-up/resume
cfi_cmdset_0001: Erase suspend on write enabled
Creating 4 MTD partitions on "omapflash.0":
0x000000000000-0x000000040000 : "bootloader"
0x000000040000-0x000000060000 : "params"
0x000000060000-0x000000260000 : "kernel"
0x000000260000-0x000004000000 : "filesystem"
OneNAND driver initializing
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <>
eth0: SMC91C94 (rev 9) at c48ae300 IRQ 309 [nowait]
eth0: Ethernet addr: 08:00:28:01:1b:92
OMAP Keypad Driver
i2c /dev entries driver
OMAP Watchdog Timer Rev 0x22: initial timeout 60 sec
TCP cubic registered
NET: Registered protocol family 17
NET: Registered protocol family 15
Power Management for OMAP2 initializing
PRCM revision 1.0
eth0: link up
IP-Config: Guessing netmask
IP-Config: Complete:
    device=eth0, addr=, mask=,
    host=, domain=, nis-domain=(none),
    bootserver=, rootserver=, rootpath=
Looking up port of RPC 100003/2 on
Looking up port of RPC 100005/1 on
VFS: Mounted root (nfs filesystem) on device 0:11.
Freeing init memory: 116K
Kernel panic - not syncing: Attempted to kill init!


But I'm getting a kernel panic. Is there anything I've missed in the
kernel configuration for Android. In the kernel I'm using there is no
configuration item for ASHMEM, WAKELOCK, etc. do they have to be
enabled? Am I using the right Android kernel?

I've also tried the omap android kernel from the following link.
git:// using branch named
This is even worse. I don't get any kernel messages output on the

Please provide me a solution for this.

Thanks and regards,


3. Mau buat aplikasi GIS jalur angkutan umum - mohon bantuannya

4. Sharing Christmas Wallpaper from flikie wallpaper (59 wallpapers)

5. SD Card File system

6. cara nyetting AndrOCS Beta di galaxy tab

7. Mod: Undangan untuk Komunitas ID-Android-Dev, Press Release 'IM2 Android Application Contest'