I am developing screen in which four buttons move horizontally from left to right and on each button click I have to open webView so can anyone suggest how to change button position so that proper on click event of button is detected .
I have read : animation actually does not moves the button but only its images. so what is proper way to add button.
I am new to stackoverflow and android animation so please suggest....
setContentView(R.layout.activity_main);
ll = (LinearLayout) findViewById(R.id.topbar);
animation = AnimationUtils.loadAnimation(this, R.anim.animation_right);
animation.setRepeatCount(TranslateAnimation.INFINITE);
animation.setRepeatMode(TranslateAnimation.RESTART);
animation.setAnimationListener(new SlidingButtonAnimationListener());
animation.setDuration(30000);
ll.startAnimation(animation);
button1=(Button)findViewById(R.id.button1);
button2=(Button)findViewById(R.id.button2);
button3=(Button)findViewById(R.id.button3);
button4=(Button)findViewById(R.id.button4);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.d(TAG, "Button1 clicked");
}
});
button2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.d(TAG, "Button2 clicked");
}
});
button3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.d(TAG, "Button3 clicked");
}
});
button2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.d(TAG, "Button4 clicked");
}
});
}
private class SlidingButtonAnimationListener implements AnimationListener {
public void onAnimationEnd(Animation animation){
}
public void onAnimationRepeat(Animation animation){}
public void onAnimationStart(Animation animation){}
}