Why is my device not showing the table? - android

I am new to Android.
I am trying to show a scrollable table.
The XML visualizer on Android Studio shows it fine, but my device is not showing it.
In my device, I can only see the first TextView(routine_heading).
What should I do to overcome this problem?
Below is the XML code I used
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/routine_heading"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/routine_header"
android:textAppearance="?android:textAppearanceLarge"/>
<ScrollView
android:id="#+id/layout"
android:layout_height="wrap_content"
android:scrollbars="horizontal|vertical"
android:layout_width="match_parent"
android:layout_marginTop="8dip"
android:scrollbarStyle="outsideOverlay"
android:fillViewport="false">
<HorizontalScrollView
android:id="#+id/horizontalView"
android:layout_height="wrap_content"
android:scrollbars="horizontal|vertical"
android:layout_width="wrap_content"
android:layout_marginTop="5dip">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/tlGridTable"
android:stretchColumns="*">
<TableRow
android:layout_weight="1">
<TextView
android:background="#drawable/cell"
android:text=""
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"/>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/cell"
android:text="10-10:50"
android:padding="3dip"
android:layout_height="match_parent"
/>
<TextView
android:text="10:50-11:40"
android:background="#drawable/cell"
android:padding="3dip"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<TextView
android:background="#drawable/cell"
android:text="11:40-12:30"
android:padding="3dip"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
/>
<TextView
android:background="#drawable/cell"
android:text="12:30-1:20"
android:padding="3dip"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
/>
<TextView
android:background="#drawable/cell"
android:text="2:35-3:20"
android:padding="3dip"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
/>
<TextView
android:background="#drawable/cell"
android:text="3:20-4:00"
android:padding="3dip"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
/>
<TextView
android:background="#drawable/cell"
android:text="4:00-4:50"
android:padding="3dip"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</TableRow>
</TableLayout>
</HorizontalScrollView>
</ScrollView>
</LinearLayout>

Problem is that you are Setting column size to stretch to its parent! where its parent is a HorizontalScrollView which has infinite width! Thus, It can't set its weight.
So, You need a to put your Table in a ScrollView (vertical) then inside the Table there is the HorizontalScrollView. Also, you need to add height m width attribute after changing it.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/routine_heading"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/routine_header"
android:textAppearance="?android:textAppearanceLarge"/>
<ScrollView
android:id="#+id/layout"
android:layout_height="wrap_content"
android:scrollbars="horizontal|vertical"
android:layout_width="match_parent"
android:layout_marginTop="8dip"
android:scrollbarStyle="outsideOverlay"
android:fillViewport="false">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/tlGridTable"
android:stretchColumns="*">
<HorizontalScrollView
android:id="#+id/horizontalView"
android:layout_height="wrap_content"
android:scrollbars="horizontal|vertical"
android:layout_width="wrap_content"
android:layout_marginTop="5dip">
<TableRow
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:background="#drawable/cell"
android:text=""
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"/>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/cell"
android:text="10-10:50"
android:padding="3dip"
android:layout_height="match_parent"
/>
<TextView
android:text="10:50-11:40"
android:background="#drawable/cell"
android:padding="3dip"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<TextView
android:background="#drawable/cell"
android:text="11:40-12:30"
android:padding="3dip"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
/>
<TextView
android:background="#drawable/cell"
android:text="12:30-1:20"
android:padding="3dip"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
/>
<TextView
android:background="#drawable/cell"
android:text="2:35-3:20"
android:padding="3dip"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
/>
<TextView
android:background="#drawable/cell"
android:text="3:20-4:00"
android:padding="3dip"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
/>
<TextView
android:background="#drawable/cell"
android:text="4:00-4:50"
android:padding="3dip"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</TableRow>
</HorizontalScrollView>
</TableLayout>
</ScrollView>
</LinearLayout>
Recommended to use a ListView/RecyclerView with a adapter for this
kind of works.

If you want a scrolling table, you generally use a ListView + an Adapter.
Each item of the Adapter should create a "row" of the "table".
Using a RecyclerView could help with the vertical and horizontal scrolling.

Add Table layout below Scrollview (into child view) like this
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:id="#+id/routine_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/app_name"
android:textAppearance="?android:textAppearanceLarge"
/>
<ScrollView
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dip"
android:fillViewport="false"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="horizontal|vertical"
>
<TableLayout
android:id="#+id/tlGridTable"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*"
>
<HorizontalScrollView
android:id="#+id/horizontalView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:scrollbars="horizontal|vertical"
>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:text=""
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="10-10:50"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="10:50-11:40"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="11:40-12:30"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="12:30-1:20"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="2:35-3:20"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="3:20-4:00"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="4:00-4:50"
/>
</TableRow>
</HorizontalScrollView>
</TableLayout>
</ScrollView>
</TableLayout>

Related

Multiple layouts, one activity

I want to create an activity that contains 5 "FrameLayout" like the picture below.
3 equal FrameLayout in the first row and 2 FrameLayout in the second row.
I did it using Linear layouts but I got a warning that nested weights are bad. So is there an other way to make it.
Fragments should be streched on the screen without using values like (100dp).
you cal also use the two table layout..
like
<TableLayout android:weight='1'>
<TableRow>
<Linear>
<FrameLayout /> <FrameLayout /> <FrameLayout />
</Linear>
</TableRow>
</TableLayout>
<TableLayout android:weight='1'>
<TableRow>
<Linear>
<FrameLayout /> <FrameLayout/>
</Linear>
</TableRow>
</TableLayout>
its rough layout . i hope you got the idea.
Try this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#00bbff" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="1" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#bb00ff" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="2" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#00ff00" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="3" />
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#bbff00">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="4" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#ffbb00" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="5" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
Try this::Hope its useful for you.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#00bbff"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="1" />
</FrameLayout>
<View android:layout_width="10dp"
android:layout_height="10dp"
/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#bb00ff"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="2"
/>
</FrameLayout>
<View android:layout_width="10dp"
android:layout_height="10dp"
/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#00ff00"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="3" />
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp">
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#bbff00" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="4" />
</FrameLayout>
<View android:layout_width="10dp"
android:layout_height="10dp"
/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#ffbb00" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="5" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
see image below ![image][1]
See This code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="2dp"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="2dp"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="1"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_marginTop="2dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="150dp"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"/>
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:gravity="center"
android:layout_marginLeft="1dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4" />
</LinearLayout>
</LinearLayout>

Android table layout issue caused by vertical divider

following is my layout for Android App,
I've tried the table layout,
It will be fine if I don't add the vertical divider.
but the problems are:
the images are not right align the center, caused by my vertical divider(linear layout).
here is my sample code:
<TableLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="*"
android:layout_centerHorizontal="true"
android:id="#+id/tableexample"
android:showDividers="middle" android:divider="?android:attr/dividerVertical"
android:layout_weight="1">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/tableRowContainer1"
>
<LinearLayout android:layout_width="0dp" android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_weight="1"
android:id="#+id/tableRowLayout1"
android:layout_centerHorizontal="true"
android:paddingTop="#dimen/example_list_padding"
>
<ImageButton android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/exampleImg1"
android:background="#android:color/transparent"
android:src="#drawable/reconstruct_icon01"/>
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:textColor="#color/example_list_color"
android:layout_centerHorizontal="true" android:textSize="#dimen/example_font_size"
android:text="Caption1" android:layout_below="#id/exampleImg1"
/>
</LinearLayout>
<LinearLayout android:layout_width="1dp" android:layout_height="wrap_content"
android:orientation="vertical" android:minWidth="1dp"
android:gravity="center"
android:id="#+id/tableRowDivider1">
<View
style="#style/Divider"
/>
</LinearLayout>
<LinearLayout android:layout_width="0dp" android:orientation="vertical"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:paddingTop="#dimen/example_list_padding"
>
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/exampleImg2"
android:background="#android:color/transparent"
android:src="#drawable/reconstruct_icon02"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal|center" android:textColor="#color/example_list_color"
android:layout_centerHorizontal="true" android:textSize="#dimen/example_font_size"
android:text="Caption2" android:layout_below="#id/exampleImg2"
/>
</LinearLayout>
</TableRow>
<TableRow>
<TextView android:background="#color/example_list_divider_color" android:layout_height="1dp"
android:layout_span="3"
/>
</TableRow>
.....
</TableLayout>
by the way, the top left one is padding programatically for testing.
if I do so, the image is right on the position, but that will cause another problem: the image will transform.
the following is what I really want.
What is the proper way to render this layout?
Thanks a lot!
i'm not sure but take a look at my layout i hope it will help you
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#android:color/darker_gray"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/myPRsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:textColor="#android:color/white"
android:text="My PRs"
/>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="0.03"
android:background="#android:color/white" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/workoutsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:layout_marginTop="5dp"
android:textColor="#android:color/white"
android:gravity="center"
android:text="Workouts"
/>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View
android:id="#+id/divider"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="#android:color/white" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.03"
android:background="#android:color/white" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:background="#android:color/white" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/tv3"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fontFamily="sans-serif-light"
android:textColor="#android:color/white"
android:gravity="center"
android:text="Timers"
android:layout_marginTop="5dp"/>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="0.03"
android:background="#android:color/white" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/tv4"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:text="Statistics"
android:textColor="#android:color/white"
android:layout_marginTop="5dp"/>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<View
android:id="#+id/divider"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_weight="1"
android:background="#android:color/white" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.03"
android:background="#android:color/white" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_weight="1"
android:background="#android:color/white" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/tv5"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:text="Box Locator"
android:textColor="#android:color/white"
android:layout_marginTop="5dp"/>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="0.03"
android:background="#android:color/white" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/tv6"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:text="Something"
android:textColor="#android:color/white"
android:layout_marginTop="5dp"/>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<View
android:id="#+id/divider"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_weight="1"
android:background="#android:color/white" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.03"
android:background="#android:color/white" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_weight="1"
android:background="#android:color/white" />
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="This area is decorative image"
android:textColor="#android:color/white"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
Go for Grid View. It's quite easy and you will achieve what you wish, also, it is supported in all screen sizes. Refer: http://developer.android.com/guide/topics/ui/layout/gridview.html

android tablelayout inside linearlayout overflows

I'm trying to create the following View:
My XML:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="14dp"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/meals_line_shadow_left" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="0" >
<TableRow
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<TextView
android:id="#+id/textDate"
style="#style/MealWizard.BigText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="text"
android:textSize="16sp" />
<ImageButton
android:id="#+id/buttonDatePicker"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingRight="7dp"
android:paddingLeft="7dp"
android:background="#null"
android:src="#drawable/general_date_button_selector" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<TextView
android:id="#+id/textTime"
style="#style/MealWizard.BigText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="15:34"
android:textSize="24sp" />
<ImageButton
android:id="#+id/buttonTimePicker"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingRight="7dp"
android:paddingLeft="7dp"
android:background="#null"
android:src="#drawable/general_time_button_selector" />
</TableRow>
</TableLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/meals_line_shadow_right" />
</LinearLayout>
The problem is that I can't see the right imageView:
I need solve that without using absolute size (It works with absolute values).
I'll be happy for any suggestions for fixing or alternatives
The solution is simple:
<TableLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:stretchColumns="0" >

how to optimize this layout?

I have this xml layout code:
<?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:gravity="center_horizontal"
android:background="#FFFFFF">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/nektaText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="10pt"
android:textAlignment="center"
android:text="example text will not be used" />
<ImageView
android:id="#+id/horilinee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:src="#drawable/horiline" />
<TableRow
android:id="#+id/table"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom" >
<Button
android:id="#+id/send"
android:text="أرسل"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<EditText
android:id="#+id/commenttext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="اكتب التعليق هنا"
android:minLines="1"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:scrollHorizontally="true"
android:scrollbars="vertical"
android:layout_weight="1"
android:singleLine="false" />
</TableRow>
<ImageView
android:id="#+id/horilineee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:src="#drawable/horiline" />
<ListView
android:id="#id/android:list"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</TableLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="#+id/tableRow0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
<ImageView
android:id="#+id/horiline"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/horiline" />
</TableRow>
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom" >
<ImageView
android:id="#+id/share"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/share" />
<ImageView
android:id="#+id/block"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/block" />
<ImageView
android:id="#+id/thumbdown"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/thumbdown" />
<ImageView
android:id="#+id/thumbup"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/thumbup" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom" >
<TextView
android:id="#+id/sharetext"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="شارك"
android:textSize="12dp" />
<TextView
android:id="#+id/blocktext"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="إبلاغ إساءة"
android:textSize="12dp" />
<TextView
android:id="#+id/dislikenumber"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textColor="#FF0000"
android:textSize="12dp" />
<TextView
android:id="#+id/likenumber"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textColor="#00FF00"
android:textSize="12dp" />
</TableRow>
</TableLayout>
</LinearLayout>
</RelativeLayout>
but it doesn't seems to be working as I want it to be. I need it like the following figure:
The problem with my code is the list view I can't stretch it to the bottom before the tablelayout. The other problem comes if the textview at the top is too long, it appears under the tablelayout and it's visible.
Also the tablelayout at the bottom shifted up when the keyboard is visible, I don't want this to happen.
Any suggestion please?
Have a single ListView in your layout. You can add other views(as shown in your diagram) as headers to the list view using addHeaderView() method. This way you will get the Scrolling effect as you desired.
Thank you all for your support. I came up with a better solution:
<?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:background="#FFFFFF"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_weight="1" >
<TextView
android:id="#+id/nektaText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="example text will not be used"
android:textAlignment="center"
android:textSize="10pt" />
</ScrollView>
<ImageView
android:id="#+id/horilinee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:src="#drawable/horiline" />
<TableRow
android:id="#+id/table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:gravity="bottom" >
<Button
android:id="#+id/send"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:text="أرسل" />
<EditText
android:id="#+id/commenttext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="اكتب التعليق هنا"
android:minLines="1"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:scrollHorizontally="true"
android:scrollbars="vertical"
android:singleLine="false" />
</TableRow>
<ImageView
android:id="#+id/horilineee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:src="#drawable/horiline" />
<ListView
android:id="#id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:drawSelectorOnTop="false"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/layout0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="end" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="#+id/tableRow0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
<ImageView
android:id="#+id/horiline"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/horiline" />
</TableRow>
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom" >
<ImageView
android:id="#+id/share"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/share" />
<ImageView
android:id="#+id/block"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/block" />
<ImageView
android:id="#+id/thumbdown"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/thumbdown" />
<ImageView
android:id="#+id/thumbup"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/thumbup" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom" >
<TextView
android:id="#+id/sharetext"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="شارك"
android:textSize="12dp" />
<TextView
android:id="#+id/blocktext"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="إبلاغ إساءة"
android:textSize="12dp" />
<TextView
android:id="#+id/dislikenumber"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textColor="#FF0000"
android:textSize="12dp" />
<TextView
android:id="#+id/likenumber"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textColor="#00FF00"
android:textSize="12dp" />
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
ScrollView needs to declare :
android:layout_above="#+id/Layout1"
Layout1 is the layout that host tableLayout1
But you will have some issues with ListView into scrollView
As there are only two Layout in your RelativeLayout, use LinearLayout. This will solve the overlap problem. Set the weight of ScrollView to keep the TableLayout at bottom.
The keyboard shift the Bottom table layout because it's mode is set to Resize. You will usually control this behavior through the android:windowSoftInputMode attribute on each definition in your AndroidManifest.xml. Set the value of this to adjustPan.

layout_weight for RelativeLayout doesn't work

There is the following code:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/activityEvaluationYesterdayValueDisplay"
android:layout_width="15dip"
android:layout_height="wrap_content"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationYesterdayValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:max="10"
android:progress="0" />
</LinearLayout>
Now I need to change LinearLayout to RelativeLayout. If I do it then RelativeLayout fill the whole screen, and it's bad. I understand that RelativeLayout doesn't use layout_weight for its work. Please, tell me, how can I fix it? I've tried to make LinearLayout wrapper for RelativeLayout, but it doesn't help.
UPDATE:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.6"
android:orientation="vertical" >
<RelativeLayout
android:background="#000000"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
</LinearLayout>
</LinearLayout>
UPDATE 2: FUll code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.5" >
<LinearLayout
android:weightSum="1.0"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.33"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9">
<TextView
android:id="#+id/activityEvaluationYesterdayValueDisplay"
android:layout_width="15dip"
android:layout_height="wrap_content"
android:text="0"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/activityEvaluationYesterdayValue"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationYesterdayValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:max="10"
android:progress="0" />
</RelativeLayout>
<TextView
android:id="#+id/TextView05"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.1"
android:gravity="center"
android:text="Yesterday"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.33"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/activityEvaluationTodayValueDisplay"
android:layout_width="20dip"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationTodayValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:max="10"
android:progress="0" />
</LinearLayout>
<TextView
android:id="#+id/TextView03"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.1"
android:gravity="center"
android:text="Today"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.33"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/activityEvaluationTomorrowValueDisplay"
android:layout_width="20dip"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationTomorrowValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:max="10"
android:progress="0" />
</LinearLayout>
<TextView
android:id="#+id/TextView02"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.1"
android:gravity="center"
android:text="Tomorrow"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="0.5" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.33"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/activityEvaluationEnergyValueDisplay"
android:layout_width="20dip"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationEnergyValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:max="10"
android:progress="0" />
</LinearLayout>
<TextView
android:id="#+id/TextView11"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.1"
android:gravity="center"
android:text="Energy"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.33"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/activityEvaluationWeatherValueDisplay"
android:layout_width="20dip"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationWeatherValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:max="10"
android:progress="0" />
</LinearLayout>
<TextView
android:id="#+id/TextView09"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.1"
android:gravity="center"
android:text="Weather"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.33"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/activityEvaluationHoursSleptValueDisplay"
android:layout_width="20dip"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationHoursSleptValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:max="10"
android:progress="0" />
</LinearLayout>
<TextView
android:id="#+id/TextView07"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.1"
android:gravity="center"
android:text="Hours Slept"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
</TableRow>
</TableLayout>
</LinearLayout>
Why RelativeLayout fill whole screen, not 0.6 ?
android:layout_weight makes sense only for LinearLayout. Lint should aware you about with a warning
RelativeLayout is the only one child who has layout_weight attribute so you should also specify weightSum:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<RelativeLayout
android:background="#ff0000"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.6">
</RelativeLayout>
</LinearLayout>

Categories

Resources