开发者

Split screen in two

I am trying to split my layout into two halves.When I try layout_weight,in splits it into two horizontal halves.How do i split the layout into two vertical halves.

          <?xml version="1.0" encoding="utf-8"?>

android:id="@+id/linearLayout123" android:layout_width="fill_parent"
android:layout_height="fill_parent">




<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_weight="1" 
                 android:layout_gravity="top" 
                 android:id="@+id/linearLayout12"
    android:layout_width="fill_parent" 
                 android:layout_height="fill_parent">


 <Button android:id="@+id/button1"            
               andro开发者_运维百科id:layout_width="wrap_content"                                          

               android:layout_height="wrap_content"           
                android:text="Hello, I am a Button" />



      </LinearLayout>



<LinearLayout android:layout_weight="1"
    android:layout_gravity="bottom" android:id="@+id/linearLayout1"
    android:layout_width="fill_parent" android:layout_height="fill_parent">


           <TextView 
            android:id="@+id/text2"              
            android:layout_width="wrap_content"             
            android:layout_height="wrap_content"              
            android:text="Hello, I am a TextView" />

       </LinearLayout>

      </LinearLayout>


Use 'orientation="vertical"' in the enclosing layout, and apply your weights to the children such as:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_gravity="fill"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:weightSum="1.0"
    android:orientation="vertical"
    android:padding="5dp"> 

<TopChildView android:layout_height="0dp"
    android:layout_weight="0.5"
    .../>

<BottomChildView android:layout_height="0dp"
    android:layout_weight="0.5"
    .../>

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜