XML : How do I align things properly in Android?

I'm trying to layout a simple CardView, where there is text on the top, and beneath that, there are a couple of those "buttons". But I can't even seem to get the layouts to align properly, and I've done it in the past (a while ago, I must admit) using layout_above and layout_below but they don't seem to be available anymore. So I've tried it some other ways, based on what I learned from the docs, but I don't think I learned much... clearaly...

To better explain what my code is trying to do, here's a pic:

CardView with text on the top, a separator and button on the bottom.

Instead of seeing what you can see in the pic above, all I see is a two layouts overlapping and the button appearing ontop of both layouts.

  <?xml version="1.0" encoding="utf-8"?>  <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"      xmlns:android="http://schemas.android.com/apk/res/android"      android:id="@+id/card_view"      android:layout_gravity="center"      android:layout_width="fill_parent"      android:layout_height="72dp"      card_view:cardCornerRadius="0.7dp"      card_view:cardElevation="1.0dp"      android:background="@color/cardview_light_background"      android:layout_marginBottom="7dp"      android:foreground="?android:attr/selectableItemBackground"      android:clickable="true">      <RelativeLayout          android:layout_width="match_parent"          android:layout_height="wrap_content"          android:gravity="fill_horizontal"          android:background="@color/linearLayoutBackgroundColor">          <TextView              android:id="@+id/cardViewTextItem"              android:layout_gravity="center"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:text="@string/cardText"              android:padding="7dp"/>      </RelativeLayout>      <RelativeLayout          android:layout_width="match_parent"          android:layout_height="wrap_content"          android:gravity="fill_horizontal"          android:background="@color/secondLinearLayoutBackgroundColor">          <Button android:text="DETAILS" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/cardview_light_background" />      </RelativeLayout>  </android.support.v7.widget.CardView>    

No comments:

Post a Comment