Below is my gridview layout which works fine and clicks. But when I change my layout it's not clicking any more. Tell me why I just change xml not code. Tell me what is wrong in my xml? Why gridView stopped clicking? is it because of layout weight?
I'm changing from this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/image2"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:padding="5dp"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/title2"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="10dp"
android:textColor="#000" />
</LinearLayout>
To this:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="#+id/image2"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_weight="1"
android:gravity="center_horizontal"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:id="#+id/title2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center_vertical"
android:textColor="#000000" />
<TextView
android:id="#+id/title3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:orientation="vertical" >
<Button
android:id="#+id/ButtonSendFeedback"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/roundshapebtn"
android:text="Order Now"
android:textColor="#ffffff"
android:textSize="15pt" />
</LinearLayout>
You have some spaces in your layout maybe your click events did not trigger becasue of this. Just use below layout and check if your problem is solved:
<?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="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="#+id/image2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#58FA58"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/title2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#DF013A" />
<TextView
android:id="#+id/title3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#2EFEF7" />
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/ButtonSendFeedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="dummy"/>
</LinearLayout>
Related
I'm trying to emulate a dock for a launcher with 3 text views evenly spaced out across said dock... For some reason I can't get my text views to center align with in there parent linear layouts, can someone please explain to me what is my issue here?
Here is my layout in XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/main_frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF" >
<LinearLayout
android:id="#+id/footer"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#99000000"
android:paddingBottom="20dp"
android:paddingTop="20dp" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:background="#drawable/launcher_footer_icon"
android:gravity="center"
android:text="Internet Browser"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:background="#drawable/launcher_footer_icon"
android:gravity="center"
android:text="Flight Tracker"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:background="#drawable/launcher_footer_icon"
android:gravity="center"
android:text="Airline Info"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Try this out, I think you have too many inner layouts.. you can use layout_weight to achieve this.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/main_frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/blue"
android:orientation="horizontal"
android:padding="20dp"
android:weightSum="15.0" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="5.0" >
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:background="#color/blue"
android:gravity="center"
android:text="Internet Browser"
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="5.0" >
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:background="#color/blue"
android:gravity="center"
android:text="Flight Tracker"
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="5.0" >
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:background="#color/blue"
android:gravity="center"
android:text="Airline Info"
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
I am trying to make a layout in android according to the image however whatever i try is just wrong.
Here's my code below.
<?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="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="8dp" >
<TextView
android:id="#+id/bottomright"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="#E5E5E5"
android:layout_weight="1"
android:gravity="bottom|right"
android:textSize="15sp"
android:text="#string/bottomright" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="8dp" >
<TextView
android:id="#+id/left"
android:layout_width="154dp"
android:layout_height="102dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:gravity="center|left"
android:layout_weight="1"
android:textSize="30sp"
android:adjustViewBounds="true"
android:maxLines="7"
android:text="" />
<TextView
android:id="#+id/topright"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="6dp"
android:gravity="top|right"
android:textSize="90sp"
android:text="topright" />
</LinearLayout>
</LinearLayout>
And here what i want to get. Maybe it is wrong to use LinearLayout? Better user Relative?
Can someone help me with this?
<?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:baselineAligned="false"
android:orientation="horizontal"
android:weightSum="4" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="2" >
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="top" />
</LinearLayout>
</LinearLayout>
Creating static xml layout's are very easy. I guess you haven't tried googling yourself.
anyways, with respect to the image, here is the code :-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/textView1"
android:layout_width="350dp"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:text="TextView" />
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="120dp"
android:layout_toRightOf="#+id/textView1"
android:text="TextView3" />
<TextView
android:id="#+id/textView3"
android:layout_width="fill_parent"
android:layout_height="120dp"
android:layout_toRightOf="#+id/textView1"
android:layout_below="#+id/textView2"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:text="TextView3" />
</RelativeLayout>
I am trying to design a screen like this one in Android:
I have all buttons, background and images in separate PNG files, but I can't get it done!
I don't know how to put the two buttons inside the background and I am having troubles with the distances from the borders as well.
Here is what I have so far:
<?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:orientation="vertical"
android:background="#drawable/fundo_tela">
<ImageView
android:id="#+id/imgtopo"
android:src="#drawable/topo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/telaInicio"
android:layout_gravity="center"
android:gravity="center"
android:textColor="#fff"
android:textSize="20dp" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#drawable/fundoBotoes" >
<Button android:id="#+id/Camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/cameraBselector">
</Button>
<Button
android:id="#+id/Galeria"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/galleryBselector">
</Button>
</LinearLayout>
<Button
android:id="#+id/Pedidos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/pedidosBselector"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
>
</Button>
</LinearLayout>
When you say "the two buttons" I assume it is the Gallery and Camera buttons you are talking about.
If I understand correctly you can do something like this (I have not testet it properly, so you might want to make some additional changes)
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="vertical"
android:background="#000000"
android:gravity="center"
>
<Button
android:id="#+id/Camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5sp"
android:background="#color/cameraBselector"
>
</Button>
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_margin="3sp"
android:background="#41383C"
/>
<Button
android:id="#+id/Galeria"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3sp"
android:background="#color/galleryBselector"
/>
</LinearLayout>
If I misunderstood something please let me know.
Try this
<?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="#drawable/fundo_tela"
android:layout_weight="100"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="20"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<ImageView
android:id="#+id/imgtopo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/topo" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="#string/telaInicio"
android:textColor="#fff"
android:textSize="20dp" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="60"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/fundoBotoes"
android:orientation="vertical" >
<Button
android:id="#+id/Camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/cameraBselector" >
</Button>
<Button
android:id="#+id/Galeria"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/galleryBselector" >
</Button>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="20"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<Button
android:id="#+id/Pedidos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginTop="15dp"
android:background="#color/pedidosBselector" >
</Button>
</LinearLayout>
</LinearLayout>
Only group the first imageview and text in a Linearlayout and the last button in other LinearLayout. With the weight attribute work like a percent, this example is 20% top, 60% body and 20% footer.
Did to look exactly what you wanted.
<?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:orientation="vertical" >
<ImageView
android:id="#+id/imgtopo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/darker_gray"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="10dp"
android:text="Selecione a opção desejada:"
android:textColor="#fff"
android:textSize="18dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="0.90"
android:background="#android:color/black"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="#+id/ButtonCamera"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:layout_margin="10dp"
android:drawablePadding="-5sp"
android:drawableTop="#android:drawable/ic_menu_camera"
android:text="Tirar Foto"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/ButtonSlideShow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:layout_margin="10dp"
android:drawablePadding="-5sp"
android:drawableTop="#android:drawable/ic_menu_slideshow"
android:text="Galeria de Foto"
android:textColor="#FFFFFF" />
</LinearLayout>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Meus Pedidos" />
</LinearLayout>
I have a layout problem, the idea is that the buttons and text dont show
<?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" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#5094c5"
android:orientation="vertical"
android:paddingBottom="8dp"
android:paddingTop="8dp" >
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/logo" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical" >
<ImageButton
android:id="#+id/buton_produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"
android:src="#drawable/icon" />
<TextView
android:id="#+id/produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Produse"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical" >
<ImageButton
android:id="#+id/buton_produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/icon" />
<TextView
android:id="#+id/produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Produse"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical" >
<ImageButton
android:id="#+id/buton_produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/icon" />
<TextView
android:id="#+id/produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Produse"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical" >
<ImageButton
android:id="#+id/buton_produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/icon" />
<TextView
android:id="#+id/produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Produse"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Set the height and width in the xml layout file to what they should be when they are visible but initially, in code, get a reference to them and make them invisible. Then, when needed, you can make them visible (in code).
Maybe better try with RelativeLayout. This seems to be too nested and too much complicated than it suppose to be.
You can give setVisibility() property to button and textview in layout.
I've got a view with a SlidingDrawer at the bottom. When I open it, it does not open entirely and stops at previous sibling view.
Anybody can help?
Thanks
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/home" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:id="#+id/top_bar"
android:layout_width="fill_parent" android:layout_height="44dp"
android:background="#drawable/top_bar">
<ImageView android:id="#+id/btn_popup"
android:layout_width="20dp" android:layout_height="20dp"
android:background="#456463" android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp" />
</RelativeLayout>
<LinearLayout android:id="#+id/featured"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="50dp" android:background="#drawable/bg_goodidea">
<TextView android:id="#+id/featured_title"
android:layout_width="280dp" android:layout_height="wrap_content" />
<TextView android:id="#+id/featured_txt"
android:layout_width="280dp" android:layout_height="wrap_content" />
</LinearLayout>
<ViewStub android:id="#+id/menu_container"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</ViewStub>
<SlidingDrawer android:id="#+id/banner"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:handle="#+id/handle" android:content="#+id/content">
<TextView android:id="#id/handle" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#drawable/bg_banner_title"
android:text="banner title" android:paddingLeft="50dp"
android:gravity="center_vertical" />
<ImageView android:id="#id/content"
android:layout_width="fill_parent" android:layout_height="100dp"
android:background="#286427" />
</SlidingDrawer>
</LinearLayout>
Layout inflated in the ViewStub:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/menu_cat_0" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="100dp"
android:layout_marginTop="10dp">
<LinearLayout android:id="#+id/cat_2" android:tag="2"
android:orientation="vertical" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:gravity="center">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="#drawable/ic_cat_2" />
<TextView android:text="#string/cat_communes"
style="#style/IconTitle" />
</LinearLayout>
<LinearLayout android:id="#+id/cat_4" android:tag="4"
android:orientation="vertical" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:gravity="center">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="#drawable/ic_cat_4" />
<TextView android:text="#string/cat_hebergements"
style="#style/IconTitle" />
</LinearLayout>
<LinearLayout android:id="#+id/cat_3" android:tag="3"
android:orientation="vertical" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:gravity="center">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="#drawable/ic_cat_3_vide" />
<TextView android:text="#string/cat_agenda" style="#style/IconTitle" />
</LinearLayout>
<LinearLayout android:id="#+id/cat_10" android:tag="10"
android:orientation="vertical" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:gravity="center">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="#drawable/ic_cat_10" />
<TextView android:text="#string/cat_meteo" style="#style/IconTitle" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Don't put it in a LinearLayout. Put it in a RelativeLayout, so it can float over top of earlier children.