I'm trying to add a FAB to the bottom of a card view, like in this app:
The button does show up, but it has a wrong height, and it should be a bit lower. I'm using Android Material Design Library. Here are my files:
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FFEB3B</color>
<color name="colorAccentDark">#FBC02D</color>
</resources>
activity_main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<LinearLayout
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/main_content"
android:layout_below="@id/toolbar">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/stop_card"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="5dp"
card_view:cardCornerRadius="4dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingTop="5dp"
android:paddingRight="10dp"
android:paddingBottom="5dp">
<TextView
android:id="@+id/label_stop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Fermata"
android:textSize="25sp"
android:textStyle="bold"
android:singleLine="true" />
<EditText
android:id="@+id/edit_stop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:layout_gravity="end" />
<com.gc.materialdesign.views.ButtonFloat
android:id="@+id/buttonFloat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#1E88E5"
materialdesign:animate="true"
materialdesign:iconDrawable="@android:drawable/ic_menu_search" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</RelativeLayout>
This is what I'm getting in Android Studio preview:
It's almost right, but it should be higher in order to contain the drawable and should be on the other end of the card view, a bit lower.
0 comments:
Post a Comment