돌핀 브라우저에서 본 적이 있습니다. 기본적으로 이미 생성 된 제스처가 있습니다. 사용자가 그리기를 시작할 위치를 알 수 있도록 다시 그리기합니다. 나는 Gesture 객체에서 toPath()라는 메소드를 발견했다. 그러나 나는 그것을 사용하는 방법에 대한 단서가 없으며 내가 올바른 방향에 있는지 확실하지 않습니다. 누군가 그것을 어떻게하는지 말해 줄 수 있습니까? 감사. 아래 사진을보실 수 있습니다.제스처가 자동으로 그려집니다.
0
A
답변
1
내가 SDK 샘플에서 GestureBuilder 응용 프로그램을 살펴보고 제안 첫째. 귀하의 질문에 정확하게 표시되어 있습니다 (작은 제스처 미리보기 이미지).
나는 약간 예를 더 명확Gesture
API를 사용 할 것을 확장 한
: GeatureBuilder에서
이 에 다음 코드를 추가 샘플 GestureBuilderActivity을 :
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
final Intent intent = new Intent(getApplicationContext(), ShowGestureActivity.class);
intent.putExtra(ShowGestureActivity.GESTURE_NAME_EXTRA, ((NamedGesture)v.getTag()).name);
startActivity(intent);
}
그것은 새로운 테스트를 시작됩니다 액티비티 GestureActivity :
onOptionsItemSelected
에는 모두 Gesture
개의 그리기 방법을 볼 수 있습니다. 보이는(GesturesBuilder 앱 자체가 해당 방법을 사용하여 목록에 제스처 축소판 그림을 표시 함). toPath
은 Gesture
에 해당하는 경로를 제공합니다. 그 후에 원하는 경로를 그리기 위해 사용할 수 있습니다. 테스트 활동에서 MyPathView
위에서 그렇게하는 가장 쉬운 방법을 제공합니다
public class MyPathView extends View {
private Paint mPaint;
private Path mPath = null;
public MyPathView(Context context) {
super(context);
init(null, 0);
}
public MyPathView(Context context, AttributeSet attrs) {
super(context, attrs);
init(attrs, 0);
}
public MyPathView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(attrs, defStyle);
}
private void init(AttributeSet attrs, int defStyle) {
mPaint = new Paint();
mPaint.setColor(Color.YELLOW);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(getResources().getDimensionPixelSize(R.dimen.paint_width));
}
public void setPath(final Path path) {
mPath = path;
invalidate();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mPath != null) {
canvas.drawPath(mPath, mPaint);
}
}
}
을 그리고 XML은 (단지 컴파일 예 쉽도록)한다 :
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container">
<com.sandrstar.testapp.test.MyPathView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myPathView"
android:visibility="gone"/>
</FrameLayout>
당신이 제스처에 애니메이션의 어떤 종류를 적용하려면 그리기, 당신은 경로를 얻을 필요가 위에서 설명한대로 사용자 정의보기를 작성하고 몇 가지 애니메이션 방법을 적용 예 여기에 설명 된 것과 같습니다 Draw path on canvas with animation
죄송합니다. 나는 지금 생각을했다. 답을 읽기 전에 [AnimatedPathView] (https://github.com/matthewrkula/AnimatedPathView)를 사용하여이 애니메이션을 완성했습니다. 그러나 제 많은 제스처가 있다고 가정 할 때, 제게 준 링크의 지시에 따라 모든 제스처마다 모든 애니메이션을 제어 할 수 있습니까? – Androidizing
모든 애니메이션을 정확히 제어한다는 것은 무엇을 의미합니까? AnimatedPathView + Animator는 애니메이션을 충분히 제어합니다. 또한 애니메이션 (예 : 시작 - 정지)을보다 잘 제어 할 수 있도록 내 대답의 링크에서보기를 쉽게 확장 할 수 있습니다. – sandrstar
나는 도서관보다는 당신의 방식을 사용하고 싶다. AnimatedPathView를 잊어 버리십시오. 지금 나는 네가 나에게 준 링크를 만들고있다. 감사합니다. – Androidizing