Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Floating Action Button not working over ListView

I have a floating action button over a listview, but I can't click on the button when the list fills up so that the button and the list overlap. In that situation only the list item is clickable. How do I rectify this issue? Thanks in advance. My xml code is below.

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">


<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/card_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="3dp"
    android:paddingBottom="10dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:paddingTop="10dp"
    card_view:cardCornerRadius="1dp"
    card_view:cardElevation="5dp">

    <RelativeLayout
        android:id="@+id/layout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/frameLayout"
        android:layout_centerHorizontal="true"
        android:layout_gravity="bottom"
        android:background="#000000"
        android:orientation="vertical"
        android:padding="1.5dp"
        android:weightSum="1">


        <TextView
            android:id="@+id/txtTitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:background="#660033"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="@android:color/primary_text_dark" />

        <RelativeLayout
            android:id="@+id/frameLayout"
            android:layout_width="fill_parent"
            android:layout_height="300dp"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:layout_marginTop="29dp"
            android:background="@android:color/darker_gray"
            android:padding="2dp">

            <TextView
                android:id="@+id/txtLocation"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/dispLoc"
                android:layout_gravity="left|top"
                android:text="[Location]"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/txtDesc"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/dispDesc"
                android:layout_gravity="left|center_vertical"
                android:layout_marginTop="1dp"
                android:text="[Description]"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/dispLoc"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_alignParentTop="true"
                android:text="@string/loc"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/dispDesc"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/txtLocation"
                android:layout_gravity="left|center_vertical"
                android:layout_marginTop="17dp"
                android:text="@string/desc"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/dispContact"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/txtDesc"
                android:layout_marginTop="25dp"
                android:text="@string/contact"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/txtContact"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/dispContact"
                android:layout_toEndOf="@+id/dispLoc"
                android:autoLink="email"
                android:text="[ContactInfo]"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/From"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/dispContact"
                android:layout_marginTop="16dp"
                android:text="@string/from"
                android:textColor="@android:color/primary_text_light" />

            <TextView
                android:id="@+id/txtStartDate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/From"
                android:layout_marginLeft="10dp"
                android:layout_toEndOf="@+id/From"
                android:text="[Start Date]"
                android:textColor="@android:color/secondary_text_light" />

            <TextView
                android:id="@+id/To"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/txtStartDate"
                android:text="@string/to"
                android:textColor="@android:color/primary_text_light" />

            <TextView
                android:id="@+id/txtEndDate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignStart="@+id/txtStartDate"
                android:layout_alignTop="@+id/To"
                android:text="[End Date]"
                android:textColor="@android:color/secondary_text_light" />

            <Button
                android:id="@+id/attend_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentStart="true"
                android:text="Attend" />

            <Button
                android:id="@+id/cancel_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignStart="@+id/txtContact"
                android:text="Cancel" />

        </RelativeLayout>

        <TextView
            android:id="@+id/txtType"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/txtTitle"
            android:layout_alignEnd="@+id/txtTitle"
            android:text="Type"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="@android:color/primary_text_dark" />


    </RelativeLayout>


</android.support.v7.widget.CardView>


<TextView
    android:id="@+id/peopleAttending"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/card_view"
    android:background="#660033"
    android:text="@string/people_attending"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@android:color/primary_text_dark" />

<org.lucasr.twowayview.TwoWayView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/lvItems"
    style="@style/TwoWayView"
    android:layout_width="match_parent"
    android:layout_height="37dp"
    android:layout_below="@+id/peopleAttending"
    android:drawSelectorOnTop="false"
    tools:context=".DetailedEventActivity" />

<com.software.shell.fab.ActionButton xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:id="@+id/action_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_marginBottom="@dimen/fab_margin"
    android:layout_marginEnd="@dimen/fab_margin"
    fab:button_color="@color/fab_material_red_500"
    fab:button_colorPressed="@color/fab_material_red_900"
    fab:hide_animation="@anim/fab_roll_to_down"
    fab:image="@drawable/fab_plus_icon"
    fab:image_size="24dp"
    fab:shadow_color="#757575"
    fab:shadow_radius="1.0dp"
    fab:shadow_xOffset="0.5dp"
    fab:shadow_yOffset="1.0dp"
    fab:show_animation="@anim/fab_roll_from_down"
    fab:stroke_color="@color/fab_material_blue_grey_500"
    fab:stroke_width="1.0dp"
    fab:type="DEFAULT"
    android:clickable="true"/>

<ListView
    android:id="@+id/commentsList"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/lvItems"
    android:layout_marginTop="0dp"
     />

like image 223
Sudharshan Venkatesh Avatar asked Dec 02 '22 17:12

Sudharshan Venkatesh


1 Answers

Move your FAB to the bottom of the XML (below the ListView).

like image 65
Frederik Schweiger Avatar answered Dec 05 '22 06:12

Frederik Schweiger