Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move (translate animation) a button with clickable area?

I'm moving a button to fade when scrolls, but when animating, the clickable area not moving! How I must move this button completely to new position?

animation

here is my code:

mBtnCompare.animate().translationY(15).alpha(0).setDuration(200);

and here is my xml:

<?xml version="1.0" encoding="utf-8"?><android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fancy="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=".acts.ActProductDetail">

<include layout="@layout/toolbar" />

<android.support.v4.widget.NestedScrollView
    android:id="@+id/actDet_Scrl"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    ... //some elements

</android.support.v4.widget.NestedScrollView>

<mehdi.sakout.fancybuttons.FancyButton
    android:id="@+id/actMain_btnCompare"
    android:layout_width="140dp"
    android:layout_height="40dp"
    android:layout_gravity="bottom|center"
    android:layout_margin="20dp"
    android:elevation="3dp"
    android:padding="2dp"
    app:layout_behavior="@string/fab_transformation_sheet_behavior"
    fancy:fb_borderColor="@color/white"
    fancy:fb_borderWidth="3dp"
    fancy:fb_defaultColor="@color/colorPrimaryDark"
    fancy:fb_radius="25dp"
    fancy:fb_text="مقایسه محصول"
    fancy:fb_textColor="@color/white"
    fancy:fb_textGravity="center"
    fancy:fb_textSize="@dimen/sub_text_size" /></android.support.design.widget.CoordinatorLayout>

Thanks in advance.

like image 559
Mahdi Moqadasi Avatar asked Nov 18 '25 06:11

Mahdi Moqadasi


1 Answers

You should use:

mBtnCompare.animate().translationY(150);

instead of:

mBtnCompare.animate().translationY(15);

setOnClickListener will work as you expect when u use a bigger value.

like image 108
Pouya Heydari Avatar answered Nov 19 '25 22:11

Pouya Heydari



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!