I have this header:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dip">
<Button android:id="@+id/home"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Home"
/>
<Button android:id="@+id/questions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My Questions"
/>
<Button android:id="@+id/questions"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Questions"
android:layout_toRightOf="@+id/home" />
<Button android:id="@+id/businesses"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Businesses"
android:layout_toRightOf="@+id/businesses"
/>
<Button android:id="@+id/learn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Learn"
android:layout_toRightOf="@+id/learn"
/>
<Button android:id="@+id/extra_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Help"
android:layout_toRightOf="@+id/learn"
/>
</RelativeLayout>
and for some reason, the buttons display 50% on top of each other all bunched up, each covering half of the other.
Any idea what is wrong with my layout?
Thanks!
You are using a relative layout, you need to manage both horizontal and vertical alignment. For example, all the android:layout_toRightOf are used for horizontal positioning, you need to also add attributes to handle the vertical positioning.
All the possible attributes are found here:
http://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html
UPDATE
Seeing your comments below, it seems you just want to have one horizontal row. In that case, just make sure each is aligned to the previous one(But then why not use a linear layout?)
Check your id’s though, and @+id/learn is aligned to the right of itself. Revisit that. And you also have a button right after “Home” that isn’t handled at all.