I need to make this kind of layout
NB: sorry for the use of old ms paint
When I click button 2, page 1(the one with listview) will scale to 0 height (kind of an accordion), and page 2 will come up with translation. And now the problem is, after it looks like the image on the right, I cant click anything on it. After some check, all the click event goes through to page 1
Here is my code for the call:
public void openButtonTop(View v){
if(!TopOpen){
scaleViewY(ll, 0f, 1f,0f,false,how_long);
translateView(
buttonTanggal,0,0,
-1*howfar,0,
how_long);
translateView(
ll2,0,0,
-1*howfar,0,
how_long);
TopOpen=true;
}
}
public void openButtonBelow(View v){
if(TopOpen){
scaleViewY(ll, 1f, 0f,0f,true,how_long);
translateView(
buttonTanggal,0,0,
0,-1*howfar,
how_long);
translateView(
ll2,0,0,
0,-1*howfar,
how_long
);
TopOpen=false;
}
}
And here is the animation function
public static void scaleViewY(final View v, float startScale, float endScale,float pivotY,final boolean gone,int how_long) {
Animation anim = new ScaleAnimation(
1f, 1f, // Start and end values for the X axis scaling
startScale, endScale, // Start and end values for the Y axis scaling
Animation.RELATIVE_TO_SELF, 0f, // Pivot point of X scaling
Animation.RELATIVE_TO_SELF, pivotY); // Pivot point of Y scaling
anim.setFillAfter(true); // Needed to keep the result of the animation
anim.setDuration(how_long);
anim.setAnimationListener(new Animation.AnimationListener() {
@Override public void onAnimationStart(Animation animation) {
//if(!gone)v.setVisibility(View.VISIBLE);
//if(!gone)translateView(v,0,0,-410,0,0);
}
@Override public void onAnimationEnd(Animation animation) {
//if(gone)v.setVisibility(View.GONE);
//if(gone)translateView(v,0,0,0,-410,0);
}
@Override public void onAnimationRepeat(Animation animation) {}
});
v.startAnimation(anim);
}
public static void translateView(View v,float fromX,float toX,float fromY, float toY,int how_long){
TranslateAnimation animation=new TranslateAnimation(fromX,toX,fromY,toY);
animation.setFillAfter(true);
animation.setDuration(how_long);
v.startAnimation(animation);
}
One solution I found the best success with is set the visibilty to GONE for the page 1, but it makes a bit of blinking after page 2 slide up.
Does anyone know how to solve this?
EDIT: page2 is an included layout