现在b2显示在一个位置,我希望它在屏幕上随机打印。我使用淡入淡出动画,但它实际上在一点淡化,我希望图像视图在屏幕上的randam位置运行。
public class page2 extends ActionBarActivity {
ImageView b2;
int count = 0;
Handler handler = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_page2);
Intent c = getIntent();
String name = c.getStringExtra("t");
Toast.makeText(getApplicationContext(), name,Toast.LENGTH_SHORT).show();
b2 = (ImageView) findViewById(R.id.redball);
Animation animation = AnimationUtils.loadAnimation(page2.this, R.anim.fade);
b2.startAnimation(animation);
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
count = count + 1;
}
});
handler = new Handler();
final Runnable t = new Runnable() {
public void run() {
Intent d = new Intent(getApplicationContext(), Page3.class);
d.putExtra("count", count);
d.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(d);
}
};
handler.postDelayed(t, 4000);
}
答案 0 :(得分:0)
您需要使用RelativeLayout作为容器,然后将LayoutParams设置为ImageView。使用b2.layout(startX,startY,endX,endY)设置位置,然后调用invalidate()