Java android roulet:当roullet旋转和roullet自动调整大小时,内部开始图像禁用
我开发了一个应用程序,因为我有轮盘赌,轮盘赌旋转得很好,但是 问题1:轮盘赌有开始的内部图像,当我单击开始时,轮盘赌旋转:当轮盘赌旋转时,我希望我的开始图像消失,当轮盘赌停止时,我希望它再次可见 问题2:我有一张固定大小的轮盘赌图像,但当轮盘赌旋转时,它会自动调整大小,我不想这样,我不知道轮盘赌为什么会自动调整大小。我想解决这个问题 我的代码如下: 代码如下所示Java android roulet:当roullet旋转和roullet自动调整大小时,内部开始图像禁用,java,android,android-animation,Java,Android,Android Animation,我开发了一个应用程序,因为我有轮盘赌,轮盘赌旋转得很好,但是 问题1:轮盘赌有开始的内部图像,当我单击开始时,轮盘赌旋转:当轮盘赌旋转时,我希望我的开始图像消失,当轮盘赌停止时,我希望它再次可见 问题2:我有一张固定大小的轮盘赌图像,但当轮盘赌旋转时,它会自动调整大小,我不想这样,我不知道轮盘赌为什么会自动调整大小。我想解决这个问题 我的代码如下: 代码如下所示 package com.example.roulette_project; import java.util.Random;
package com.example.roulette_project;
import java.util.Random;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class SpinActivity extends Activity {
boolean clickcount = false;
ImageView switchon;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_spin);
switchon = (ImageView) findViewById(R.id.imageSwitchOn);
final ImageView roullete = (ImageView) findViewById(R.id.wheel_image);
final ImageView innerroullete = (ImageView) findViewById(R.id.innerroullete);
final Animation anim1 = AnimationUtils.loadAnimation(SpinActivity.this,
R.anim.wheel_spin_anim);
final Animation anim2 = AnimationUtils.loadAnimation(SpinActivity.this,
R.anim.innner_roullete_animation);
final Animation anim3 = AnimationUtils.loadAnimation(SpinActivity.this,
R.anim.from_middle);
final View l = findViewById(R.id.flipId);
final TextView team1 = (TextView) findViewById(R.id.textView1);
final TextView team2 = (TextView) findViewById(R.id.textView2);
final View full = findViewById(R.id.full_view);
full.setRotationX(30);
// innerroullete.setRotationY(30);
// innerroullete.setRotationX(20);
// Display display = getWindowManager().getDefaultDisplay();
// Point size = new Point();
// display.getSize(size);
// int width = size.x;
// int height = size.y;
// roullete.getLayoutParams().height=height/2;
// roullete.getLayoutParams().width=width/2;
switchon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// int SPLASH_TIME_OUT = 3000;
//
//
// new Handler().postDelayed(new Runnable() {
//
// /*
// * Showing splash screen with a timer. This will be useful when you
// * want to show case your app logo / company
// */
//
// @Override
// public void run() {
// switchon.setVisibility(View.GONE);
// }
// }, SPLASH_TIME_OUT);
// switchon.setVisibility(View.VISIBLE);
roullete.startAnimation(anim1);
// innerroullete.startAnimation(anim2);
roullete.animate().rotation(2);
// switchon.setVisibility(View.GONE);
int i2, i1 = 0;
Random r = new Random();
i2 = r.nextInt(2);
i1 = r.nextInt(360);
Toast.makeText(getApplicationContext(),
"angle = " + getAnswer(i1), Toast.LENGTH_LONG).show();
// float i2 = 360/i1;
// Toast.makeText(getApplicationContext(), "angle = " +i1,
// Toast.LENGTH_LONG).show();
Bitmap myImg = BitmapFactory.decodeResource(getResources(),
R.drawable.roulete_hd);
roullete.setImageBitmap(myImg);
Matrix matrix = new Matrix();
matrix.postRotate(i1);
l.startAnimation(anim2);
l.startAnimation(anim3);
Log.d("ROTATIING :- ", i1 + ": start");
Bitmap rotated = Bitmap.createBitmap(myImg, 0, 0,
myImg.getWidth(), myImg.getHeight(), matrix, true);
roullete.setImageBitmap(rotated);
// for (int i = 0; i < 10; i++) {
// if (i % 2 == 0) {
// try {
// new Thread().sleep(1000);
// team1.setText("IND");
// team2.setText("PAK");
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//
// } else {
// team1.setText("PAK");
// team2.setText("IND");
// }
//
// }
if (i2 == 1) {
team1.setText("IND");
team2.setText("PAK");
} else {
team1.setText("PAK");
team2.setText("IND");
}
}
});
}
public int getAnswer(int i) {
if (i >= 17 && i <= 49) {
return 5;
} else if (i >= 50 && i <= 81) {
return 4;
} else if (i >= 82 && i <= 114) {
return 3;
} else if (i >= 115 && i <= 147) {
return 2;
} else if (i >= 148 && i <= 180) {
return 1;
} else if (i >= 181 && i <= 212) {
return 11;
} else if (i >= 213 && i <= 245) {
return 10;
} else if (i >= 246 && i <= 278) {
return 9;
} else if (i >= 279 && i <= 310) {
return 8;
} else if (i >= 311 && i <= 343) {
return 7;
} else {
return 6;
}
}
}
这很简单,只需在动画末尾添加一个侦听器
private OnClickListener onClick = new OnClickListener(){
@Override
public void onClick(View v){
v.setOnClickListener = null;
wheel.animate().addListener(animatorListener)... the rest of your animation
}
};
然后在动画结束时,删除侦听器并重新添加单击侦听器
private AnimatorListenerAdapter animatorListener = new AnimatorListenerAdapter(){
@Override
public void onAnimationEnd (Animator animation){
animation.removeListener(this);
button.setOnClickListener(onClick);
}
}
你能粘贴一些代码吗?