Wednesday, December 16, 2009

Started to work with Android platform. You know what?! For the 4th day in a row I am sitting with a smile on my face!
after BREW & Symbian this is GREAT!
Problem:
Missing in layout of the views Java SE  java.awt.BorderLayout analogue.
Answer:
Use combination of nested layouts to simulate BorderLayout. Below is a definition of a view ready for use. Simply nest your components
inside LinearLayout tags.
The idea comes from here.
<LinearLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent">
       <LinearLayout
             android:id="@+id/top_container"
             android:orientation="horizontal"
             android:layout_weight="0"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content">      
             <!-- Add here the TOP components --> 

       </LinearLayout> 
       <!-- Central row -->
       <LinearLayout
              android:orientation="horizontal"
              android:layout_weight="1"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">
              <LinearLayout
                     android:id="@+id/left_container" 
                     android:orientation="vertical"
                     android:layout_weight="0"
                     android:layout_width="wrap_content"
                     android:layout_height="fill_parent">
                     <!-- Add here the LEFT components -->

              </LinearLayout>
              <LinearLayout
                     android:id="@+id/center_container"
                     android:orientation="vertical"
                     android:layout_weight="1" 
                     android:layout_width="fill_parent"
                     android:layout_height="fill_parent">
                     <!-- Add here the CENTER components -->

              </LinearLayout>
              <LinearLayout
                     android:id="@+id/right_container"
                     android:orientation="vertical"
                     android:layout_weight="0"
                     android:layout_width="wrap_content"
                     android:layout_height="fill_parent">
                     <!-- Add here the RIGHT components -->

              </LinearLayout>
       </LinearLayout>
       <LinearLayout
              android:id="@+id/bottom_container"
              android:orientation="horizontal"
              android:layout_weight="0"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content">
              <!-- Add here the BOTTOM components -->

       </LinearLayout>
</LinearLayout>

No comments:

Followers