elL
elL

Reputation: 777

Android- Proper positioning of layouts

I cant seem to properly position my layouts the way I want them to be. What my layout looks like is like this:

LinearLayout
  LinearLayout
      ListView

  LinearLayout
      TextView
      TextView
      TextView
      Button   

My aim is to have it like this:

enter image description here

Any thoughts on this please as to what Layouts i will use?

Help will be appreciated

Upvotes: 3

Views: 988

Answers (3)

KDeogharkar
KDeogharkar

Reputation: 10959

try this

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/homeTableLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
     >

 <LinearLayout
     android:layout_centerInParent="true"
     android:layout_width="fill_parent"
    android:layout_height="100dip"
    android:background="@android:color/holo_blue_dark"
    >
    <!-- arrange your lables and button here -->

    </LinearLayout>
   <LinearLayout
    android:layout_width="100dip"
    android:layout_height="fill_parent" 
    android:background="@android:color/holo_purple"
    android:layout_marginLeft="20dip"
    >
       <ListView
           android:layout_width="fill_parent" 
           android:layout_height="fill_parent"

           ></ListView>
   </LinearLayout>
</RelativeLayout>

look the wireframe below . you can set corner-radius and add controls in it.
enter image description here

Upvotes: 2

deepa
deepa

Reputation: 2494

You can use the Relative layout for this as follows

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

    <RelativeLayout
        android:id="@+id/first_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="20dip" >

        <Button
            android:id="@+id/btn1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <Button
            android:id="@+id/btn2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/btn1" />

        <Button
            android:id="@+id/btn3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/btn2" />

        <Button
            android:id="@+id/btn4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/btn3" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/second_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_toRightOf="@+id/first_layout" >

        <GridView
            android:id="@+id/gridview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
        </GridView>

        <Button
            android:id="@+id/btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true" />
    </RelativeLayout>

</RelativeLayout>

Upvotes: 0

Jignesh Ansodariya
Jignesh Ansodariya

Reputation: 12695

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/layout2"
    android:layout_width="fill_parent"
    android:layout_height="200dip"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true" >

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="100dip"
        android:layout_weight="1" >
    </ListView>
</LinearLayout>

<LinearLayout
    android:id="@+id/layout1"
    android:layout_width="100dip"
    android:layout_height="fill_parent"
    android:layout_alignParentLeft="true"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="TextView" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="TextView" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="TextView" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="TextView" />
</LinearLayout>


</RelativeLayout>

Upvotes: 0

Related Questions