Here’s the code:
<RelativeLayout
android:id="@+id/top_lay2"
android:layout_below="@id/top_lay1"
android:layout_width="fill_parent"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:layout_height="wrap_content"
android:background="@drawable/customrect">
<TextView
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrao_content"
android:textColor="@color/white1"
android:text="some text"
/>
<Button
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="click me"
/>
</RelativeLayout>
From that xml code, I except that the views will be displayed vertically relative to the other, but instead they stack on each other. What’s wrong here?
In a LinearLayout, your fields would be displayed vertically. But in a RelativeLayout, you have to specify where they are relative to each other. So, if you replace “RelativeLayout” by “LinearLayout”, you’re all set.