android-flat-button
android-flat-button copied to clipboard
Clicking on a button which is close to another one causes animation to be played on both buttons
Only happens if they both have shadow enabled and are close to each other
example code:
<info.hoang8f.widget.FButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Hello"
fbutton:buttonColor="#8074feb4"
fbutton:shadowEnabled="true"
fbutton:shadowHeight="8dp"
android:textColor="#FF000000"
fbutton:cornerRadius="0dp"/>
<info.hoang8f.widget.FButton
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_width="wrap_content"
android:text="World"
fbutton:buttonColor="#8074feb4"
fbutton:shadowEnabled="true"
fbutton:shadowHeight="8dp"
android:textColor="#FF000000"
fbutton:cornerRadius="0dp"/>
Happen with me too.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<info.hoang8f.widget.FButton
android:id="@+id/btn_to_date"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="From Date"
android:textAppearance="?android:attr/textAppearanceButton"
android:textColor="@color/white"
fbutton:buttonColor="@color/orange_500"
fbutton:cornerRadius="3dp"
fbutton:shadowColor="@color/grey_700"
fbutton:shadowEnabled="true"
fbutton:shadowHeight="2dp" />
<View
android:layout_width="10dp"
android:layout_height="1dp" />
<info.hoang8f.widget.FButton
android:id="@+id/btn_from_date"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="To Date"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceButton"
android:textColor="@color/white"
fbutton:buttonColor="@color/orange_500"
fbutton:cornerRadius="3dp"
fbutton:shadowColor="@color/grey_700"
fbutton:shadowEnabled="true"
fbutton:shadowHeight="2dp" />
</LinearLayout>
Happen with me too. How to deal with it?

The problem isn't they are near. The problem comes with setPadding at onTouchEvent. You have both buttons at same LinearLayout and setting padding to one flatbutton moves the other one due to padding. This move effect seems like a click but isn't a real click, just your shadow is hidding because is moving out the linearlayout.
You can "fix" it if you set this buttons in a RelativeLayout or inside a FrameLayout
Hope it helps!