Floating button setOnClickListener not gets called in Android
<p>I want to integrate movable floating button same like <strong>"WhatsApp"</strong> Application When open, it displays <em>hike floating button</em> with motion. And also working click event. </p>

<p>I used with default <code>OnTouch</code> event it's working but I can't apply Click event on floating button. How can I apply both <strong>Click and touch event</strong> ?</p>

<p>Thanks in advance! </p>

<p><strong>home.xml</strong></p>

<pre><code> &lt;RelativeLayout
        android:id="@+id/rl_parent_floating"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="visible"&gt;

        &lt;RelativeLayout xmlns:fab="http://schemas.android.com/apk/res-auto"
            android:id="@+id/rl_floating_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentBottom="true"
            android:layout_margin="10dp"&gt;

            &lt;TextView
                android:id="@+id/txtCartCount"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_alignRight="@+id/fab"
                android:layout_alignTop="@+id/fab"
                android:background="@drawable/cart_gold_circle"
                android:gravity="center"
                android:singleLine="true"
                android:text="2"
                android:textColor="@android:color/white"
                android:textSize="8sp" /&gt;

            &lt;com.melnykov.fab.FloatingActionButton
                android:id="@+id/fab"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="3dp"
                android:src="@drawable/ic_floating_cart"
                fab:fab_colorNormal="@color/header_color_red"
                fab:fab_colorPressed="@color/colorPrimaryDark"
                fab:fab_colorRipple="@color/gold_color" /&gt;
        &lt;/RelativeLayout&gt;
    &lt;/RelativeLayout&gt;
</code></pre>

<p><strong>Home.java</strong></p>

<pre><code>     mFloatingActionButton = (FloatingActionButton) findViewById(R.id.fab);
            mRrootLayout = (ViewGroup) findViewById(R.id.rl_floating_button);
            rl_floating_button = (RelativeLayout) findViewById(R.id.rl_floating_button);
            rl_parent_floating = (RelativeLayout) findViewById(R.id.rl_parent_floating);
mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent mIntent = new Intent(mActivity, Cart.class);
                startActivity(mIntent);
            }
        });

            mFloatingActionButton.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View view, MotionEvent event) {

                    final int X = (int) event.getRawX();
                    final int Y = (int) event.getRawY();

                    switch (event.getAction() &amp; MotionEvent.ACTION_MASK) {
                        case MotionEvent.ACTION_DOWN:
                            RelativeLayout.LayoutParams lParams = (RelativeLayout.LayoutParams) view.getLayoutParams();
                            view.getLayoutParams();

                            _xDelta = X - lParams.leftMargin;
                            _yDelta = Y - lParams.topMargin;
                            break;
                        case MotionEvent.ACTION_UP:
                            break;
                        case MotionEvent.ACTION_POINTER_DOWN:
                            break;
                        case MotionEvent.ACTION_POINTER_UP:
                            break;
                        case MotionEvent.ACTION_MOVE:
                            RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) view
                                    .getLayoutParams();
                            layoutParams.leftMargin = X - _xDelta;
                            layoutParams.topMargin = Y - _yDelta;
                            layoutParams.rightMargin = 0;
                            layoutParams.bottomMargin = 0;
                            view.setLayoutParams(layoutParams);
                            break;
                    }
                    mRrootLayout.invalidate();
                    return true;
                }
            });
</code></pre>