Answer the question
In order to leave comments, you need to log in
How to make a proper ViewPager?
I made the ViewPager work fine, but there are Buttons inside the pager, and when you try to scroll the pager, the buttons are also pressed if you hit them. On the buttons I have OnTouch something like this
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (view.getId()){
case R.id.btnZero:
switch (motionEvent.getAction()){
case MotionEvent.ACTION_DOWN:
relativeZero.setBackgroundColor(transparent);
setMargin(btnZero,3,3,3,3);
if (result != null && result.length() <= 11){
result += "0";
txtTablo.setText(result);
}
break;
case MotionEvent.ACTION_UP:
relativeZero.setBackgroundResource(R.drawable.back_button_2);
setMargin(btnZero,0,0,0,3);
break;
}
break;
private void setMargin(Button btn, int left, int top, int rigth, int botom){
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) btn.getLayoutParams();
params.setMargins(left,top,rigth,botom);
btn.setLayoutParams(params);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question