5 月のアプリでは、2 つのアニメーションがあります。1つは画面の下から上に向かって成長しています。私の startNewAnimation() メソッド内で呼び出されます。
mSurfaceGrowingAnimation = new TranslateAnimation(0, 0, mViewHeight, 0);
mSurfaceGrowingAnimation.setInterpolator(new LinearInterpolator());
このメソッドは、このメソッド内で呼び出されます。
ViewTreeObserver observer = ViewTimer.getViewTreeObserver();
observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
@SuppressWarnings("deprecation")
public void onGlobalLayout() {
Log.d(TAG, "onGlobalLayout");
mViewHeight = ViewTimer.getHeight();
startNewAnimation();
ViewTimer.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
});
私の他のアニメーションは、スライド ボタンのように機能します。アニメーションを停止するために使用されます。
@Override
public boolean onTouch(View view, MotionEvent event) {
AbsoluteLayout.LayoutParams layoutParams = (AbsoluteLayout.LayoutParams) view.getLayoutParams();
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_UP:
showDialog();
pauseAnimation();
int endOfAnimation = findViewById(R.id.slide_included).getWidth() - mSlideView.getWidth();
mSlideAnimation = new TranslateAnimation(event.getX(), endOfAnimation - layoutParams.x, 0, 0);
mSlideAnimation.setDuration(1000);
mSlideAnimation.setFillAfter(true);
mSlideView.startAnimation(mSlideAnimation);
break;
case MotionEvent.ACTION_MOVE:
layoutParams.x = (int) event.getRawX();
view.setLayoutParams(layoutParams);
break;
}
つまり、スライド ビューを移動するときに、メイン アニメーションをクリアする pauseAnimation() メソッドを呼び出します。
問題は次のとおりです。メインのアニメーションが停止すると、それがスライド ボタンの下にある場合、スライド ビューの上部までペイントされます。どうすればこれを修正できますか?
これは私のレイアウトです:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frame_main"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/time_view"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<View
android:id="@+id/surface_view_timer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="0dp"
android:background="#77B21B00" />
</RelativeLayout>
<include
android:id="@+id/slide_included"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_margin="20dp"
layout="@layout/slide" />
</FrameLayout>
スライド.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/slide_layout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_margin="20dp"
android:background="#0000FF" >
<View
android:id="@+id/slide_to_pause"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#00FFFF" />
</AbsoluteLayout>