package com.yxkang.android.percent.sample;

import android.os.Bundle;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;

public class CollapsingActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_collapsing);

        Toolbar toolbar = (Toolbar) this.findViewById(R.id.tool_bar);
        setSupportActionBar(toolbar);

        CollapsingToolbarLayout collapsingToolbar =
                (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
        collapsingToolbar.setTitle("Title");
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}

@@ -63,16 +63,67 @@
 Bundle;%0A
+import android.support.design.widget.AppBarLayout;%0A
 import a
@@ -168,32 +168,32 @@
 gToolbarLayout;%0A
-
 import android.s
@@ -292,16 +292,49 @@
 ew.Menu;
+%0Aimport android.view.MotionEvent;
 %0A%0Apublic
@@ -388,16 +388,117 @@
 vity %7B%0A%0A
+    private static final String TAG = %22CollapsingActivity%22;%0A%0A    private AppBarLayout appBarLayout;%0A%0A
     @Ove
@@ -897,24 +897,24 @@
 g_toolbar);%0A
-
         coll
@@ -945,16 +945,719 @@
 Title%22);
+%0A%0A        appBarLayout = (AppBarLayout) findViewById(R.id.app_bar);%0A    %7D%0A%0A    @Override%0A    public boolean dispatchTouchEvent(MotionEvent ev) %7B%0A        switch (ev.getAction()) %7B%0A            case MotionEvent.ACTION_UP:%0A                float range = appBarLayout.getTotalScrollRange();%0A                float height = appBarLayout.getMeasuredHeight();%0A                float offset = appBarLayout.getBottom() + range - height;%0A                float rate = offset / range;%0A                if (rate %3C= 0.8f) %7B%0A                    appBarLayout.setExpanded(false, true);%0A                %7D%0A                break;%0A            default:%0A                break;%0A        %7D%0A        return super.dispatchTouchEvent(ev);
 %0A    %7D%0A%0A

add AppBarLayout extend anim