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=" http://schemas.android.com/apk/res/ 
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <gomoku.com.BoardView
android:id="@+id/gomoku"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>

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

Thanks,
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.

--
RichardC




--


Sponsored Links


Other Threads

1. WiFi on eeePC 1000HE?

Hi,

I have just built the new android-x86 from (http://code.google.com/p/
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?

Thanks!

--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

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

Hi,

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?

Regards,
Jamie.
--
http://www.linuxuk.org

--~--~---------~--~----~------------~-------~--~----~

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?