How to change the height of a view

by jdekeij » Wed, 11 Nov 2009 03:53:08 GMT

Sponsored Links
 I use the following layout to define a gameboard.

<LinearLayout xmlns:android=" 

All works fine, however I want the gameboard to appear as square. So I
need to resize the board at runtime to put it in the center of the
screen and make it square. I tried many options without success :(

Help is very much appreciated

Jasper de Keijzer


How to change the height of a view

by RichardC » Wed, 11 Nov 2009 04:06:46 GMT

 I can answer 1/2 your question

You need to implement onMeasure  in your custom view class and call
setMeasuredDimension when you have calculated the largest square your
want your custom view to occupy.

Centering a view in its parent container I do not know how to do.



Sponsored Links

Other Threads

1. Applications not visible on Magic in Germany


I've posted an issue at the market help site, but thought I would
mention it here as well to see if anyone has come across the same

I'm a UK developer and I was in Germany yesterday. A friend had an HTC
Magic on Vodafone D2 and I was worried to find that neither of my
applications were visible, either by browsing or searching.

Both are priced, with copy protection enabled, and I have selected
'all current and future markets'.

Soon after I got my HTC Magic I found that my apps weren't visible on
that either (even though I tried searching and even though the browse
list appeared to have finished updating). I raised an issue then, but
an hour or so later they appeared so I thought nothing more of it.

I'm finding this really disconcerting - either there's some country/
operator specific filtering going on that I'm not aware of, or maybe
the whole system is just flaky?

2. Module version conflicts between wlan module and Android kernel source


  I'm tinkering with building and installing Android from source.
Basically I've got it down fairly well, but I seem to have run into a
bit of a problem with the wlan module, probably from HTC.

  Having pulled the 2.6.27 kernel sources and built that with
a .config pulled from the phone, and using that as the kernel image
instead of the prebuilt one, I get the following wifi failure message
in dmesg:

wlan: version magic '2.6.27-00205-gf2dabc0 preempt mod_unload ARMv6 '
should be '2.6.27-00392-g8312baf preempt mod_unload ARMv6 '

probably because the .config I pulled from the phone has:


So I rebuilt with the '00205' localversion and now I get in dmesg:

[   61.122497] wlan: Unknown symbol trout_pwrsink_set

but trout_pwrsink_set was changed to htc_pwrsink_set way back in

[ARM]: trout: Switch from trout_pwrsink -> htc_pwrsink  33/8933/1;a=commitdiff;h=44a01f...

  I'm clearly getting an obsolete wlan module somehow, Any ideas for
how I can get a wlan module that goes with the '00392' kernel would be


3. Module version conflicts between wlan module and Android kernel source

4. Module version conflicts between wlan module and Android kernel source

5. Null reference to ImageView from custom view

6. Market countries - how are they determined ?

7. ( problem for experts ) update/refresh list problem