I have three views 1)Toolbar
2)Edittext
and Recyclerview
. Now on click on edittext
i want to animate the toolbar
to the top(out of screen generally) up along with edittext
and recyclerview
.The animation works fine but the problems is that the recycler view is not taking the full height.The recycler view is moved to the top but also recyclerview
is not taking the full height
XMl
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff">
<include
android:id="@+id/tb_explore"
layout="@layout/toolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></include>
<LinearLayout
android:id="@+id/ll_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/tb_explore"
android:layout_marginLeft="05dp"
android:layout_marginRight="05dp"
android:layout_marginTop="07dp"
android:focusable="false"
android:orientation="horizontal">
<AutoCompleteTextView
android:id="@+id/et_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/imageView11"
android:layout_toStartOf="@+id/imageView11"
android:background="@android:color/transparent"
android:hint="Search by vendor name or keyword"
android:padding="10dp"
android:imeOptions="actionGo"
android:singleLine="true"
android:textSize="@dimen/regular" />
<TextView
android:id="@+id/tv_cancel"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:gravity="center"
android:text="Cancel"
android:visibility="gone" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_explore_search"
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_below="@+id/ll_search"
android:layout_marginTop="10dp"
android:background="#efd3d3"
android:visibility="visible" />
Code
rlHeader.animate()
.translationY(-rlHeader.getHeight());
llSearch.animate()
.translationY(-rlHeader.getHeight())
.setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
rvExplore.getLayoutParams().height = rvExplore.getHeight() + rlHeader.getHeight(); //here i am increasing the height but no use
rvExplore.animate().translationY(-rlHeader.getHeight());
}
@Override
public void onAnimationEnd(Animator animation) {
etSearch.requestFocus();
tvCancel.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});