0

I made a button bar that contains some buttons in it, I faced two problems:

The first one is that when the buttons fill the width of the screen the new ones begin to behave wrongly: see from here

I had try setting width to wrap_content and some fixed values but both didn't work.

The second one is that I want the buttons to appear like if they are merged in the buttonbar and only separated by simple lines, Like That.

here's my xml:

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".Home" >

    <LinearLayout
        android:id="@+id/grid1"
        android:layout_width="875dp"
        android:layout_height="500dp"
        android:layout_centerInParent="true"
        android:background="@android:color/darker_gray"
        android:orientation="vertical" >
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:gravity="top"
        style="@android:style/ButtonBar" >

        <Button
            android:id="@+id/Main"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:text="@string/main"
            android:layout_weight="1"/>

        <Button
            android:id="@+id/HomeView"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_toRightOf="@+id/Main"
            android:text="@string/homeview" />

        <Button
            android:id="@+id/Lighting"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_toRightOf="@+id/HomeView"
            android:text="@string/lighting" />

        <Button
            android:id="@+id/A.C."
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_toRightOf="@+id/Lighting"
            android:text="@string/ac" />

        <Button
            android:id="@+id/Profiles"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_toRightOf="@+id/A.C."
            android:text="@string/profiles" />

        <Button
            android:id="@+id/Movies"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_toRightOf="@+id/Profiles"
            android:text="@string/movies" />

        <Button
            android:id="@+id/Music"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_toRightOf="@+id/Movies"
            android:text="@string/music" />

        <Button
            android:id="@+id/TVShows"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_toRightOf="@+id/Music"
            android:text="@string/tvshows" />

        <Button
            android:id="@+id/Remote"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_toRightOf="@+id/TVShows"
            android:text="@string/remote" />
    </LinearLayout>

</RelativeLayout>
MRefaat
  • 515
  • 2
  • 8
  • 22

1 Answers1

0

1) What Layout do you use?

Try to use LinearLayout and set each item layout_weihgt = 1 in XML. Also item's width must be match_parent.

2) You must create custom layout for buttons.

Val
  • 4,225
  • 8
  • 36
  • 55