I have a tablelayout with weights for a 4 button grid. The problem is that I have on button that is in a relative layout in a tablerow which doesn't format correctly. If I have the height set to wrap content the result is this:
If I set it to fill_parent:
I can't get the button to properly fill its height weight. If I take out the relative layout it works fine. I've tried putting both in separate linear layouts to no avail.
Here is my code:
<TableLayout
android:id="#+id/tableLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/linearLayout"
android:layout_margin="10dp"
android:weightSum="2" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:minHeight="100dp" >
<Button
android:id="#+id/searchBtn"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:background="#drawable/yellow_btn"
android:minHeight="100dp"
android:text="Search"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:minHeight="100dp" >
<Button
android:id="#+id/savedBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/yellowds"
android:minHeight="100dp"
android:text="Saved Searches"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/newItemsOverlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/savedBtn"
android:layout_alignTop="#+id/savedBtn"
android:background="#drawable/badge_circle"
android:text="10"
android:textColor="#FFF"
android:textSize="16sp"
android:textStyle="bold" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="30dip"
android:layout_weight="1"
android:minHeight="100dp" >
<Button
android:id="#+id/checkNowBtn"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:background="#drawable/yellowds"
android:minHeight="100dp"
android:text="Check Now"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
<Button
android:id="#+id/settingsBtn"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:background="#drawable/yellowds"
android:minHeight="100dp"
android:text="Settings"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
Try with this :
<?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="wrap_content" >
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</LinearLayout>
<TableLayout
android:id="#+id/tableLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/linearLayout"
android:layout_margin="10dp"
android:weightSum="2" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:minHeight="100dp" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5" >
<Button
android:id="#+id/searchBtn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#cccccc"
android:minHeight="100dp"
android:text="Search"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5" >
<Button
android:id="#+id/savedBtn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#cccccc"
android:minHeight="100dp"
android:text="Saved Searches"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/newItemsOverlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/savedBtn"
android:layout_alignTop="#+id/savedBtn"
android:background="#ff0000"
android:text="10"
android:textColor="#FFF"
android:textSize="16sp"
android:textStyle="bold" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="30dip"
android:layout_weight="1"
android:minHeight="100dp" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5" >
<Button
android:id="#+id/checkNowBtn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#cccccc"
android:minHeight="100dp"
android:text="Check Now"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5" >
<Button
android:id="#+id/settingsBtn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#cccccc"
android:minHeight="100dp"
android:text="Settings"
android:textColor="#1d357d"
android:textSize="20dp"
android:textStyle="bold" />
</RelativeLayout>
</TableRow>
</TableLayout>
</RelativeLayout>
This will solve your problem.
Thanks.
Related
When I have an application filled with text, when I scroll down to see the end of the text, it must show me a background at the end .. I wrote this but it shows the background in the middle - I think
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/bglow"
android:layout_alignParentBottom="true"
android:layout_marginBottom="0dip"
android:gravity="bottom" />
How can I put a background at the end?
Edited
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:gravity="center" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/bglow"
android:layout_alignParentBottom="true"
android:layout_marginBottom="0dip"
android:gravity="bottom" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center"
android:orientation="vertical"
android:textStyle="italic" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="7sp" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:src="#drawable/1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="15sp" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:src="#drawable/logoline" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="5sp" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center_vertical"
android:orientation="horizontal"
android:textStyle="italic"
android:weightSum="100" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="60"
android:gravity="center"
android:src="#drawable/2" />
<Button
android:id="#+id/h"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="40"
android:background="#drawable/buttoncolor"
android:gravity="left"
android:text="H"
android:textColor="#AD9C64"
android:textSize="25sp"
android:textStyle="italic"
android:typeface="serif" />
</LinearLayout>
</ScrollView>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="15sp" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center_vertical"
android:orientation="horizontal"
android:textStyle="italic"
android:weightSum="100" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="60"
android:gravity="center"
android:src="#drawable/3" />
<Button
android:id="#+id/r"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="40"
android:background="#drawable/buttoncolor"
android:gravity="left"
android:text="R"
android:textColor="#AD9C64"
android:textSize="25sp"
android:textStyle="italic"
android:typeface="serif" />
</LinearLayout>
</ScrollView>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="15sp" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center_vertical"
android:orientation="horizontal"
android:textStyle="italic"
android:weightSum="100" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="60"
android:gravity="center"
android:src="#drawable/4" />
<Button
android:id="#+id/4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="40"
android:background="#drawable/buttoncolor"
android:gravity="left"
android:text="D"
android:textColor="#AD9C64"
android:textSize="22sp"
android:textStyle="italic"
android:typeface="serif" />
</LinearLayout>
</ScrollView>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="7sp" />
<Button
android:id="#+id/ab"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/buttoncolor"
android:gravity="center"
android:text="About"
android:textColor="#AD9C64"
android:textSize="10sp"
android:textStyle="italic"
android:typeface="serif" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text=""
android:textSize="7sp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
I have this code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/fondo"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context=".Inicio" >
<ViewFlipper
android:id="#+id/flipper1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_margin="40dp"
android:layout_weight="1"
android:fillViewport="true" >
<ImageView
android:id="#+id/rotacion1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="#string/img_desc"
android:scaleType="fitXY"
android:src="#drawable/rotacion1" />
<ImageView
android:id="#+id/rotacion2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="#string/img_desc"
android:scaleType="fitXY"
android:src="#drawable/rotacion2" />
</ViewFlipper>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="100dp"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal"
android:paddingTop="1dp" >
<TextView
android:id="#+id/textBienve"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#30c2c2c2"
android:clickable="true"
android:drawablePadding="5dp"
android:drawableTop="#drawable/ic_bienvel"
android:gravity="center_horizontal"
android:onClick="menu1"
android:text="#string/menu1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fff" />
<TextView
android:id="#+id/textMenudia"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:layout_marginLeft="1dp"
android:layout_weight="1"
android:background="#30c2c2c2"
android:clickable="true"
android:drawablePadding="5dp"
android:drawableTop="#drawable/ic_menu"
android:gravity="center_horizontal"
android:onClick="menu2"
android:text="#string/menu2"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fff" />
<TextView
android:id="#+id/textEspeciali"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:layout_marginLeft="1dp"
android:layout_weight="1"
android:background="#30c2c2c2"
android:clickable="true"
android:drawablePadding="5dp"
android:drawableTop="#drawable/ic_espec"
android:gravity="center_horizontal"
android:onClick="menu3"
android:text="#string/especialidades"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fff" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="100dp"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal"
android:paddingBottom="1dp"
android:paddingTop="1dp" >
<TextView
android:id="#+id/textCeleb"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#30c2c2c2"
android:clickable="true"
android:drawablePadding="5dp"
android:drawableTop="#drawable/ic_celeb"
android:gravity="center_horizontal"
android:onClick="menu4"
android:text="#string/menu4"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fff" />
<TextView
android:id="#+id/textProvee"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:layout_marginLeft="1dp"
android:layout_weight="1"
android:background="#30c2c2c2"
android:clickable="true"
android:drawablePadding="5dp"
android:drawableTop="#drawable/ic_prove"
android:gravity="center_horizontal"
android:onClick="menu5"
android:text="#string/menu5"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fff" />
<TextView
android:id="#+id/textLocalic"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:layout_marginLeft="1dp"
android:layout_weight="1"
android:background="#30c2c2c2"
android:clickable="true"
android:drawablePadding="5dp"
android:drawableTop="#drawable/ic_local"
android:gravity="center_horizontal"
android:onClick="menu6"
android:text="#string/menu6"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fff" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/ImageView01"
android:layout_width="0dp"
android:layout_height="55dp"
android:layout_weight="1"
android:contentDescription="#string/fondo"
android:src="#drawable/iconossocialesf" />
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="55dp"
android:layout_weight="1"
android:background="#30c2c2c2"
android:gravity="center_vertical|center_horizontal"
android:onClick="mostrardialog"
android:text="#string/contacto"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="0dp"
android:layout_height="55dp"
android:layout_weight="1"
android:contentDescription="#string/fondo"
android:src="#drawable/iconossocialest" />
</LinearLayout>
i need that the viewflipper go fluid, but this is not even shown and not adjust to my screen.if I put a size such 200DP all my layouts go down or up according to the screen size, i only want to adjust all the layouts to max screen size.
what I do wrong?
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.
I ahve made a simple activity in that i have used scrollView but its not working and shows error,so i have removed scrollView..Friends i need is all the menus should be included to scrollView..Please can anyone suggest me wher7e should i place the "scrollView" tag in my activity.
my activity is as below:
main-menu.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/kevingreen" android:background="#000" android:layout_weight="1"/>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.3"
android:background="#fffff3"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="fill_parent"
android:layout_height="190dp" >
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:orientation="vertical" >
<ImageButton
android:id="#+id/imageButtonVideos"
android:layout_width="fill_parent"
android:layout_height="115dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:background="#0000"
android:scaleType="centerCrop"
android:src="#drawable/balcony_pic" />
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:text="Videos"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout7"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ImageButtonTraining2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:background="#0000"
android:scaleType="centerCrop"
android:src="#drawable/crowd_pic" />
<TextView
android:id="#+id/TextView02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.6"
android:gravity="center"
android:text="Training"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout8"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ImageButtonCalculator"
android:layout_width="fill_parent"
android:layout_height="94dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:background="#0000"
android:scaleType="fitCenter"
android:src="#drawable/calculator" />
<TextView
android:id="#+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.6"
android:gravity="center"
android:text="Property Calculator"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="fill_parent"
android:layout_height="148dp"
android:layout_marginBottom="10dp" >
<LinearLayout
android:id="#+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ImageButtonShop"
android:layout_width="fill_parent"
android:layout_height="77dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:background="#0000"
android:scaleType="centerCrop"
android:src="#drawable/compra" />
<TextView
android:id="#+id/TextView03"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:text="Shop"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ImageButtonAboutKevin"
android:layout_width="fill_parent"
android:layout_height="82dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:background="#0000"
android:scaleType="centerCrop"
android:src="#drawable/about_me_pic" />
<TextView
android:id="#+id/TextView04"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:text="About Kevin"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout03"
android:layout_width="84dp"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ImageButtonLinks"
android:layout_width="fill_parent"
android:layout_height="88dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:background="#0000"
android:scaleType="fitCenter"
android:src="#drawable/coaching_pic" />
<TextView
android:id="#+id/TextView05"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.88"
android:gravity="center"
android:text="Social"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayoutthird"
android:layout_width="match_parent"
android:layout_height="102dp"
android:layout_marginBottom="10dp" >
<LinearLayout
android:id="#+id/LinearLayoutsubthird"
android:layout_width="298dp"
android:layout_height="fill_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_weight="0.83"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ImageButtonBlog"
android:layout_width="130dp"
android:layout_height="102dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#0000"
android:scaleType="centerCrop"
android:src="#drawable/blogger" />
<TextView
android:id="#+id/TextViewblogger"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:text="Blogger"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayoutabout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout android:layout_width="fill_parent" android:id="#+id/LinearLayoutabout" android:layout_height="fill_parent" android:layout_marginBottom="10dp" android:layout_marginTop="10dp" android:layout_weight="1" android:orientation="vertical">
<ImageButton android:id="#+id/ImageButtonContactUs" android:layout_width="130dp" android:layout_height="102dp" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="40dp" android:background="#0000" android:scaleType="centerCrop" android:src="#drawable/contact_us_478x318"/>
<TextView android:id="#+id/TextViewcontactus" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:gravity="center" android:text="Contact Us" android:textAppearance="?android:attr/textAppearanceMediumInverse" android:textStyle="bold"/>
</LinearLayout>
<ImageButton
android:id="#+id/ImageButtonContactUs"
android:layout_width="130dp"
android:layout_height="182dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="40dp"
android:background="#0000"
android:scaleType="centerCrop"
android:src="#drawable/contact_us_478x318" />
<TextView
android:id="#+id/TextViewcontactus"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:text="Contact Us"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1" android:background="#drawable/gradient_grey">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" android:orientation="vertical">
<ImageButton
android:id="#+id/imageButtonHome"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/g3570" android:layout_weight="0.6" android:background="#0000" android:scaleType="fitCenter" android:layout_marginTop="5dp"/>
<TextView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Home"
android:gravity="center" android:textAppearance="?android:attr/textAppearanceMediumInverse" android:textColor="#fff" android:textStyle="bold"/>
</LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" android:orientation="vertical">
<ImageButton
android:id="#+id/imageButtonTraining"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/g4404" android:layout_weight="0.6" android:scaleType="fitCenter" android:background="#0000" android:layout_marginTop="5dp"/>
<TextView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Training"
android:gravity="center" android:textAppearance="?android:attr/textAppearanceMediumInverse" android:textColor="#fff" android:textStyle="bold"/>
</LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" android:orientation="vertical">
<ImageButton
android:id="#+id/imageButtonContactUs"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/icon_email" android:layout_weight="0.6" android:scaleType="fitCenter" android:background="#0000" android:layout_marginTop="5dp"/>
<TextView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Contact Us"
android:gravity="center" android:textAppearance="?android:attr/textAppearanceMediumInverse" android:textColor="#fff" android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Please tell me where should i place scrollView tag so that it will work properly..Thank you in advance.!
Put all your views in a parent layout and then add ScrollView to that parent layout in xml. As ScrollView can be added to only one child. Hope this helps.
Place the <ScrollView> after first <ImageView> tag and place your menu items in a single <LinearLayout> tag as ScrollView works only for a single child.
I am trying to build a complex listview item layout with all of the elements being the same dimensions for each listview item with the entire layout taking up the whole width of the screen. So far I have attempted doing this using a linearlayout and found that this is the wrong approach. I have then attempted using a relative layout however this has not worked for me so I hope that someone can point out how I can make this work.
Here is a diagram of what I am trying to build.
Here is some more details about the diagram:
Only elements 5 and 6 have the same content for every list item. The
rest of elements all will have different text however the layout
should always be the same size.
Element 4 should only be 2 lines. Elements 1, 2 and 3 should only be 1
line.
Element 2 should be aligned left and element 3 should be aligned
right.
Element 2 and 3 should each be half of the width of element 4.
Here is my attempt at this layout using a RelativeLayout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="2dp">
<TextView
android:id="#+id/txtRaceNumber"
android:layout_width="20dp"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center"
android:layout_gravity="center"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" />
<TextView
android:id="#+id/txtRaceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_toRightOf="#id/txtRaceNumber"
android:layout_alignParentTop="true" />
<TextView
android:id="#+id/txtRaceClass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:maxLines="1"
android:ellipsize="marquee"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_toRightOf="#id/txtRaceNumber" />
<TextView
android:id="#+id/txtRaceStartTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:maxLines="1"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#id/txtRaceClass" />
<ImageButton
android:id="#+id/btnTracklist"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#null"
android:paddingRight="8dip"
android:focusable="false"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#id/txtRaceStartTime" />
<ImageView
android:src="#drawable/go"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_toRightOf="#id/btnTracklist" />
</RelativeLayout>
Using this RelativeLayout all of the elements appear scrambled within the layout.
How can I get all of these elements to align as I have shown in the Diagram?
Is this what you need?
<LinearLayout
android:id="#+id/lin1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:orientation="vertical" >
<TextView
android:id="#+id/txtRaceNumber"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center"
android:text="TExt1"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toRightOf="#+id/lin1"
android:layout_toLeftOf="#+id/lin3">
<TextView
android:id="#+id/txtRaceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text4"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtRaceClass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="text2"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/txtRaceStartTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="text3"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/lin3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/btnTracklist"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#null"
android:focusable="false"
android:paddingRight="8dip" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:src="#drawable/ic_launcher" />
</LinearLayout>
try this code
<?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="90dp"
android:gravity="center|left"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="left|center"
android:layout_gravity="center"
android:gravity="center"
android:text="TextView"
android:textColor="#FFFFFF"
android:textSize="15sp" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left|center"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center"
android:text="TextView"
android:textColor="#FFFFFF"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left|center"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center"
android:layout_weight="1"
android:text="TextView"
android:textColor="#FFFFFF"
android:textSize="15sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center"
android:layout_weight="1"
android:text="TextView"
android:textColor="#FFFFFF"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left|center" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginRight="3dp"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:src="#drawable/ic_launcher"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginRight="3dp"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:src="#drawable/ic_launcher"
/>
</LinearLayout>
</LinearLayout>
I have managed to get the desired layout using weightSum on the main layout.
Here is the code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/twolinechecked"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:maxHeight="?android:attr/listPreferredItemHeight"
android:paddingTop="2dip"
android:paddingBottom="2dip"
android:orientation="horizontal"
android:weightSum="1"
android:descendantFocusability="blocksDescendants">
<TextView
android:id="#+id/txtRaceNumber"
android:layout_width="40dip"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center"
android:layout_gravity="center"
android:paddingRight="5dip"
android:paddingLeft="5dip"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginLeft="6dip">
<TextView
android:id="#+id/txtRaceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:id="#+id/linearTextInner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_vertical|center_horizontal">
<TextView
android:id="#+id/txtRaceClass"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:maxLines="1"
android:ellipsize="marquee"
android:layout_alignParentLeft="true" />
<TextView
android:id="#+id/txtRaceStartTime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="1"
android:maxLines="1"
android:layout_alignParentRight="true"
android:gravity="right" />
</LinearLayout>
</LinearLayout>
<ImageButton
android:id="#+id/btnTracklist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:layout_marginLeft="5dip"
android:paddingRight="8dip"
android:layout_gravity="center_vertical|center_horizontal" />
<ImageView
android:src="#drawable/go"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_alignParentRight="true" />
</LinearLayout>
Follow below structure I feel you can achieve what you want use weight and weightSum.
<LinearLayout orientation="horizontal">
<LinearLayout>
<TextView/>
</LinearLayout>
<LinearLayout orientation="vertical">
<TextView/>
<LinearLayout orientation="horizontal">
<TextView/>
<TextView/>
</LinearLayout>
<ImageButton/>
<ImageView/>
</LinearLayout>
EDIT
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="2dp"
android:weightSum="1" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="0.2" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:orientation="vertical"
android:weightSum="1" >
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="0.7"
android:gravity="center" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="0.3"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center" />
<TextView
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
<ImageButton
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="0.15" />
<ImageButton
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="0.15" />
</LinearLayout>