开发者

How to do such a layout in xml? Android

开发者 https://www.devze.com 2023-01-08 22:40 出处:网络
I want a Layout that is as big as the screen with two rowsand three columns 开发者_JS百科 like that image =>

I want a Layout that is as big as the screen with two rows and three columns

开发者_JS百科

like that image => http://dl.dropbox.com/u/2024237/Bildschirmfoto-DroidDraw.png

the colors should be buttons...

please help .... i cant figure it out


Using LinearLayouts and setting the children to fill_parent on both width and height and assigning them the same layout_weight you would get the desired effect:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">

    <LinearLayout 
        android:orientation="horizontal"
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <Button 
            android:text="Button 1"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"></Button>
        <Button 
            android:text="Button 2"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"></Button>
        <Button 
            android:text="Button 3"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"></Button>
    </LinearLayout>
    <LinearLayout
        android:orientation="horizontal"
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <Button 
            android:text="Button 4"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"></Button>
        <Button 
            android:text="Button 5"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"></Button>
        <Button 
            android:text="Button 6"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"></Button>
    </LinearLayout>
</LinearLayout>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号