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. WiFi on eeePC 1000HE?


I have just built the new android-x86 from (
android-x86/) and created a bootable USB key, it starts up and runs on
my 1000HE and everything looks good except the WiFi won't start.  Has
anyone managed to get WiFi working on this PC or is it one of the WiFi
chipsets still waiting for support?



2. Using loadData() rather than loadUrl() and intercepting urls?


In my app I need to populate the header fields of a url request to a
server which gives me back html as a response. This is then loaded
into a webview and displayed.

Currently I'm using HttpPost to send the headers+data and using
loadData() to display the result in a webview. The problem is that the
server can send back dummy urls which are meant to be handled by the
app itself. It seems shouldOverrideUrlLoading() is only available when
you do a loadUrl() and not when a loadData() is called.

Any idea's how to work around this one?



3. After Killing Task, Android is not launching correct Activity

4. dual SD card + camera folder location on SD card

5. getting the pictures taken with my program to appear in gallery

6. Get images from web

7. how to get images from a library?