Jamie Smith
Jamie Smith

Reputation: 131

Floating Action Button is unclickable?

The FAB had worked previously when i used a FrameLayout, however when i added the FAB xml code under a new LinearLayout and changed the parent layout to RelativeLayout, it doesn't seem to respond to my Clicks anymore.

Here's the xml...

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<ListView
    android:id="@+id/song_list"
    android:layout_width="fill_parent"
    android:layout_height="455dp"
    android:divider="@color/colorPrimary"
    android:dividerHeight="1dp"
    android:scrollbarSize="20dp"
    android:scrollbarThumbVertical="@drawable/custom_listview_scrollbar"/>

<LinearLayout
    android:id="@+id/library_footer"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="@layout/bg_player_footer"
    android:layout_gravity="bottom">

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:background="@color/colorPrimary"
        android:layout_width="86dp"
        android:layout_height="86dp"
        android:layout_margin="10dp"
        android:scaleType="center"
        android:src="@drawable/player_bt"
        android:clickable="true" />

</LinearLayout>

</RelativeLayout>

And here's the onClick method for the FAB...

FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                ((FabListener) getActivity()).onFabSelected();

            }
        });

Any solutions? Thanks!

EDIT

Nevermind. Android Studio's 2.0 Instant Run seemed to be the reason behind the issue. Just needed to do a full rebuild.

Upvotes: 0

Views: 873

Answers (1)

Sofiane Hassaini
Sofiane Hassaini

Reputation: 315

Why do you use a LinearLayout ? I don't think that it's necessary.

Try to remove this and add

android:clickable="true"

in the FloatingActionButton tag

Upvotes: 1

Related Questions