Hi Vitaly,

You can set the layout weights using xml only, you do not need to do this
programatically, though you could if you wanted to.

To demonstrate how to do this:
1) Create a new test application and update your main.xml with the following
code:
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
                                   android:orientation="vertical"

android:layout_width="wrap_content"
                               android:layout_height="fill_parent"
                               android:layout_weight="1.0"

                                       >
                                        <ImageButton id="@+id/btn1"
                                       android:layout_width="wrap_content"
                                       android:layout_height="wrap_content"
                                       android:src="@drawable/icon"
                                        android:layout_weight="0.9"
                                       />

                                       <ImageButton id="@+id/btn2"
                                       android:layout_width="wrap_content"
                                       android:layout_height="wrap_content"
                                       android:src="@drawable/icon"
                                        android:layout_weight="0.1"
                                       />

       </LinearLayout>

2) Run your application and see how the first button occupies 90% of the
space and the other one occupies 10% of the screen space.
3) Change the Layout_weight of both the buttons to "0.5" and run your
application to see what happens. You can play around with it to understand
the concept.

Thanks,
Megha

On Mon, Mar 24, 2008 at 4:18 AM, vitvikt <[EMAIL PROTECTED]> wrote:

>
> Thanks, Megha
>
> But not all is clear for me.
> I did not understand, is it sufficient use only xml layouts or I have
> to change layouts in programm (in java text)?
> Using only xml layouts dosn't give me desired result.
> If I have to change layouts in programm, I don't now how can I replace
> constructions in xml
>
>    <LinearLayout
>        android:layout_width="fill_parent"
>        android:layout_weight="0"
>        android:layout_height="wrap_content">
>        <com.google.android.ww2.WWView
>        android:id="@+id/ww"
>                android:layout_width="fill_parent"
>            android:layout_height="300px"/>
>        </LinearLayout>
> to construction in java text. This cnstruction I got from Snake
> example.
> In forum I find examples of creation LinearLayout, but how can I
> transform
>
>        android:id="@+id/ww"
>                android:layout_width="fill_parent"
>            android:layout_height="300px"/>
>
> to java text?
> Now I have
> mWwView = (WWView) findViewById(R.id.ww);
>
> Thanks,
> Vitaly
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to