0

我有 3 个 imageview 按钮在点击时从外部滑入屏幕(使用翻译动画)

我也有带有 ontouch 侦听器的不可见图像视图,可以更改屏幕中心的图片:

dddd


问题是当我点击垂直矩形时没有出现 3 个按钮!但是logcat确实显示该方法已被触发,但是当我用滑动手势将图像旋转到中心时-按钮确实出现了(滑入/滑出屏幕)

public class Page7 extends Activity{
public void onCreate(){
//..... some findViewbyId stuff here

button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (launch_animation_counter == 0) {
                    Log.d("x", " show buttons");//this appears in logcat
                        launch_animation_counter = 1;
                        play.startAnimation(play_move_right);//this line does not always launch animation!
                        content.startAnimation(content_move_right);
                        record.startAnimation(record_move_right);
                    } else if (launch_animation_counter == 1) {
                    Log.d("x", " hide buttons");
                        launch_animation_counter = 0;
                        play.startAnimation(play_move_left);
                        content.startAnimation(content_move_left);
                        record.startAnimation(record_move_left);
                    }
            }
        });
swipe_area.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
//                Log.d("x", "swipe touched....");
                switch (event.getAction()){
                    case MotionEvent.ACTION_DOWN:
                        x1 = event.getRawX();
                        break ;
                    case MotionEvent.ACTION_UP:
                        x2 = event.getRawX();
                        if(x1 < x2){
                            Log.d("x", "слева направо");
                            switch (pencil_counter){
                                case 1:
                                    Log.d("x", " case 1");
                                    image.setBackgroundResource(R.drawable.page7_pencils7);
                                    pencil_counter = 7 ;
                                    break ;
                                case 2:
                                    Log.d("x", " case 2");
                                    image.setBackgroundResource(R.drawable.page7_pencils1);
                                    pencil_counter = 1 ;
                                    break ;

}

这些是动画代码:

play_move_right = new TranslateAnimation(
            Animation.ABSOLUTE, 0,
            Animation.ABSOLUTE, -240,
            Animation.ABSOLUTE, 0,
            Animation.ABSOLUTE, 0
    );
    play_move_right.setFillEnabled(true);
    play_move_right.setDuration(500);

    play_move_left = new TranslateAnimation(
            Animation.ABSOLUTE, 0,
            Animation.ABSOLUTE, 240,
            Animation.ABSOLUTE, 0,
            Animation.ABSOLUTE, 0
    );
    play_move_left.setFillEnabled(true);
    play_move_left.setDuration(500);
4

0 回答 0