parent
29ccf4fa6a
commit
fba3ed4ee1
@ -0,0 +1,71 @@ |
|||||||
|
package com.flurgle.camerakit.demo; |
||||||
|
|
||||||
|
import android.animation.Animator; |
||||||
|
import android.animation.AnimatorListenerAdapter; |
||||||
|
import android.content.Context; |
||||||
|
import android.support.annotation.NonNull; |
||||||
|
import android.support.annotation.Nullable; |
||||||
|
import android.util.AttributeSet; |
||||||
|
import android.view.LayoutInflater; |
||||||
|
import android.widget.FrameLayout; |
||||||
|
import android.widget.ImageView; |
||||||
|
|
||||||
|
public class FocusMarkerLayout extends FrameLayout { |
||||||
|
|
||||||
|
private FrameLayout mFocusMarkerContainer; |
||||||
|
private ImageView mFill; |
||||||
|
|
||||||
|
public FocusMarkerLayout(@NonNull Context context) { |
||||||
|
super(context, null); |
||||||
|
} |
||||||
|
|
||||||
|
public FocusMarkerLayout(@NonNull Context context, @Nullable AttributeSet attrs) { |
||||||
|
super(context, attrs); |
||||||
|
LayoutInflater.from(getContext()).inflate(R.layout.layout_focus_marker, this); |
||||||
|
|
||||||
|
mFocusMarkerContainer = (FrameLayout) findViewById(R.id.focusMarkerContainer); |
||||||
|
mFill = (ImageView) findViewById(R.id.fill); |
||||||
|
|
||||||
|
mFocusMarkerContainer.setAlpha(0); |
||||||
|
} |
||||||
|
|
||||||
|
public void focus(float mx, float my) { |
||||||
|
int x = (int) (mx - mFocusMarkerContainer.getWidth() / 2); |
||||||
|
int y = (int) (my - mFocusMarkerContainer.getWidth() / 2); |
||||||
|
|
||||||
|
mFocusMarkerContainer.setTranslationX(x); |
||||||
|
mFocusMarkerContainer.setTranslationY(y); |
||||||
|
|
||||||
|
mFocusMarkerContainer.animate().setListener(null).cancel(); |
||||||
|
mFill.animate().setListener(null).cancel(); |
||||||
|
|
||||||
|
mFill.setScaleX(0); |
||||||
|
mFill.setScaleY(0); |
||||||
|
mFill.setAlpha(1f); |
||||||
|
|
||||||
|
mFocusMarkerContainer.setScaleX(1.36f); |
||||||
|
mFocusMarkerContainer.setScaleY(1.36f); |
||||||
|
mFocusMarkerContainer.setAlpha(1f); |
||||||
|
|
||||||
|
mFocusMarkerContainer.animate().scaleX(1).scaleY(1).setStartDelay(0).setDuration(330) |
||||||
|
.setListener(new AnimatorListenerAdapter() { |
||||||
|
@Override |
||||||
|
public void onAnimationEnd(Animator animation) { |
||||||
|
super.onAnimationEnd(animation); |
||||||
|
mFocusMarkerContainer.animate().alpha(0).setStartDelay(750).setDuration(800).setListener(null).start(); |
||||||
|
} |
||||||
|
}).start(); |
||||||
|
|
||||||
|
mFill.animate().scaleX(1).scaleY(1).setDuration(330) |
||||||
|
.setListener(new AnimatorListenerAdapter() { |
||||||
|
@Override |
||||||
|
public void onAnimationEnd(Animator animation) { |
||||||
|
super.onAnimationEnd(animation); |
||||||
|
mFill.animate().alpha(0).setDuration(800).setListener(null).start(); |
||||||
|
} |
||||||
|
}).start(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,7 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:shape="oval"> |
||||||
|
|
||||||
|
<solid android:color="#77FFFFFF" /> |
||||||
|
|
||||||
|
</shape> |
@ -0,0 +1,9 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:shape="oval"> |
||||||
|
|
||||||
|
<stroke |
||||||
|
android:width="1.5dp" |
||||||
|
android:color="@android:color/white" /> |
||||||
|
|
||||||
|
</shape> |
@ -0,0 +1,24 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
|
||||||
|
<FrameLayout |
||||||
|
android:id="@+id/focusMarkerContainer" |
||||||
|
android:layout_width="55dp" |
||||||
|
android:layout_height="55dp"> |
||||||
|
|
||||||
|
<ImageView |
||||||
|
android:id="@+id/fill" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:src="@drawable/focus_marker_fill" /> |
||||||
|
|
||||||
|
<ImageView |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:src="@drawable/focus_marker_outline" /> |
||||||
|
|
||||||
|
</FrameLayout> |
||||||
|
|
||||||
|
</FrameLayout> |
Loading…
Reference in new issue