A
A
Alexander2014-04-01 19:06:12
Java
Alexander, 2014-04-01 19:06:12

How to animate appearance of RelativeLayout in android?

By default, this layer is in the "View.GONE" state, how to make a normal fadeIn for RelativeLayout?

if(isShowSearchBar)
{
  searcthBar.setVisibility(View.GONE);
}
else
{
  searcthBar.setVisibility(View.VISIBLE);
  textBar.requestFocus();
}			
isShowSearchBar = !isShowSearchBar;

What happened...
public void slideIn(View view)
{
  TranslateAnimation animate = new TranslateAnimation(0,0,-view.getHeight(),0);
  animate.setDuration(500);
  animate.setFillAfter(true);
  view.startAnimation(animate);
  view.setVisibility(View.VISIBLE);
}
public void slideOut(View view)
{
  TranslateAnimation animate = new TranslateAnimation(0,0,0,-view.getHeight());
  animate.setDuration(500);
  animate.setFillAfter(true);
  view.startAnimation(animate);
  view.setVisibility(View.GONE);
}
// в OnClick
if(infoShowing)
        slideOut(infoLayout);
else 
        slideIn(infoLayout);
        
infoShowing = !infoShowing;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question