Я пытаюсь увеличить RecyclerView
высоту при нажатии кнопки, а затем уменьшить ее при нажатии кнопки с анимацией.
Он правильно увеличивается и уменьшается, но анимация не работает.
Вот мой код.
public void expand(View view) {
Button button = (Button) view;
if(button.getText().toString().equalsIgnoreCase("INCREASE")) {
button.setText("DECREASE");
final int height = (int) (recyclerView.getHeight() * 2.5);
Animation a = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
FrameLayout.LayoutParams lp =
new FrameLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, height);
lp.gravity = Gravity.BOTTOM;
recyclerView.setLayoutParams(lp);
}
};
a.setDuration(2000); // in ms
recyclerView.startAnimation(a);
}
else
{
button.setText("INCREASE");
final int height = (int) (recyclerView.getHeight() / 2.5);
Animation a = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
FrameLayout.LayoutParams lp =
new FrameLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, height);
lp.gravity = Gravity.BOTTOM;
recyclerView.setLayoutParams(lp);
}
};
a.setDuration(2000); // in ms
recyclerView.startAnimation(a);
}
}
Как мне это сделать? Я не хочу растягивать это. Я хочу увеличить его высоту с помощью некоторого анимационного эффекта.