动画到顶部时增加视图的高度

时间:2016-02-10 13:28:36

标签: android viewpropertyanimator

我有三个观点1)Toolbar 2)EdittextRecyclerview。现在点击edittext我想将toolbar设置为顶部(通常在屏幕外)以及edittextrecyclerview。动画效果很好,但问题仍然存在是回收者视图没有占据整个高度。回收者视图移动到顶部但recyclerview没有占据整个高度

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" />

代码

 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) {

                    }
                });

0 个答案:

没有答案