Skip to content

Instantly share code, notes, and snippets.

const UserCard = ({ user, withAvatar }) => {
return (
<div>
{ withAvatar && <img src={user.avatarUrl}/> }
<span>
{user.name}
</span>
<span>
{user.info}
</span>
const UserCard = ({ user, withAvatar }) => {
return (
<div>
{ withAvatar && <img src={user.avatarUrl}/> }
<span>
{user.name}
</span>
<span>
{user.info}
</span>
const UserCard = ({ user, withAvatar }) => {
return (
<div>
{ withAvatar && <img src={user.avatarUrl}/> }
<span>
user.name
</span>
<span>
user.info
</span>
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) {
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);
}
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();
}
<?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"/>
<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"
<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" />
<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" />