Question

I`m trying to create a menu that will hold four ImageButtons next to each other and will be relative in size in order to support different screens resolutions.

Below the menu I need an additional small image button.

Here how it looks in Eclipse:

http://i.stack.imgur.com/QMvcs.jpg

This is how i built it in menu.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rlMain"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/abs__background_holo_dark"
    android:orientation="vertical"
    android:weightSum="1" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.95"
        android:orientation="vertical"
        android:weightSum="1" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.5"
            android:orientation="horizontal"
            android:weightSum="1" >

            <ImageButton
                android:id="@+id/newsItem"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="0.5"
                android:onClick="NewsClicked" />

            <ImageButton
                android:id="@+id/imageItem"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="0.5"
                android:onClick="TeamsClicked" >
            </ImageButton>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.5"
            android:orientation="horizontal"
            android:weightSum="1" >

            <ImageButton
                android:id="@+id/chatItem"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="0.5"
                android:onClick="ChatClicked" >
            </ImageButton>

            <ImageButton
                android:id="@+id/teamItem"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="0.5"
                android:onClick="ImagesClicked" />
        </LinearLayout>
    </LinearLayout>

    <ImageButton
        android:layout_weight="0.05"
        android:id="@+id/orderDigital"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:onClick="DigitalClicked" />

</LinearLayout>

But on my phone it displays like this:

http://i.stack.imgur.com/cyQoc.png

Can you suggest another way to build that?

Was it helpful?

Solution

Problem solved. I forgot that there was another layout(master page) that actually parent of main layout and it was with height=wrap content

Thanks :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top