Skip to content

Instantly share code, notes, and snippets.

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="line"
android:pathData="M5.705,5.705 L18.295,18.295"
android:strokeWidth="2"
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="sequentially">
<!-- first we need to immediately reset state -->
<objectAnimator
android:duration="0"
android:propertyName="trimPathStart"
android:valueFrom="0.45"
android:valueTo="0.45"/>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="together">
<objectAnimator
android:propertyName="trimPathStart"
android:valueFrom="0"
android:valueTo="0.6"
android:duration="450" />
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="together">
<objectAnimator
android:propertyName="trimPathStart"
android:valueFrom="0.4"
android:valueTo="0"
android:duration="600" />
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/searchback_search">
<target
android:name="line"
android:animation="@animator/line_to_cancel" />
<target
android:name="circle1"
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container"
android:background="#06ff87"/>
View dismiss = findViewById(R.id.dismiss);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) dismiss.getLayoutParams();
SwipeDismissBehavior<View> behavior = new SwipeDismissBehavior<>();
behavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END);
behavior.setListener(new SwipeDismissBehavior.OnDismissListener() {
@Override
public void onDismiss(final View view) {
finish();
}
public class SwipeDismissOnlyOnViewBehavior<V extends View> extends SwipeDismissBehavior<V> {
/**
* Handle only touches on this current view
*/
@Override
public boolean onTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
if (parent.isPointInChildBounds(child, (int) event.getX(), (int) event.getY())) {
return super.onTouchEvent(parent, child, event);
}
final View container = findViewById(R.id.container);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) container.getLayoutParams();
final CoordinatorLayout.Behavior<View> behavior = new CoordinatorLayout.Behavior<View>() {
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
return dependency.getId() == R.id.dismiss;
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
const UserCard = ({ user, withAvatar }) => {
return (
<div>
{ withAvatar && <img src={user.avatarUrl}/> }
<span>
{user.name}
</span>
<span>
{user.info}
</span>