package com.vily.newscroll2;
import android.content.Context;
import android.os.Bundle;
import android.os.SystemClock;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.scwang.smartrefresh.header.FlyRefreshHeader;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreater;
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import java.util.ArrayList;
import java.util.List;
public class ScrollingActivity extends AppCompatActivity {
private static final String TAG = "ScrollingActivity";
private FrameLayout mLlf;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_scrolling);
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
SmartRefreshLayout refreshLayout = findViewById(R.id.refreshLayout);
SmartRefreshLayout.setDefaultRefreshHeaderCreater(new DefaultRefreshHeaderCreater() {
@Override
public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
return new ClassicsHeader(context);//指定为经典Header,默认是 贝塞尔雷达Header
}
});
//
// final SwipeRefreshLayout refresh = findViewById(R.id.refresh);
// refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
// @Override
// public void onRefresh() {
// refresh.setRefreshing(false);
// }
// });
mLlf = findViewById(R.id.llf);
mLlf.postDelayed(new Runnable() {
@Override
public void run() {
PullUpDragLayout2 mDragLayout = new PullUpDragLayout2(ScrollingActivity.this, mLlf.getHeight());
mLlf.addView(mDragLayout);
}
},2000);
RecyclerView rv_recycle = findViewById(R.id.rv_recycle);
rv_recycle.setLayoutManager(new LinearLayoutManager(ScrollingActivity.this));
List<String> list=new ArrayList<>();
for(int i=0;i<20;i++){
list.add("sadadad");
}
TextAdapter adpter=new TextAdapter(list);
rv_recycle.setAdapter(adpter);
// MyViewDragHelper mViewDragHelper = MyViewDragHelper.create(this, 1.0f, mCallback);
final ImageView iv_img = findViewById(R.id.iv_img);
AppBarLayout app_bar = findViewById(R.id.app_bar);
app_bar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
Log.i(TAG, "onOffsetChanged: -------:"+i);
if(i>=0){
return;
}
if(i<=-600){
return;
}
float offset = Math.max((600 + i)*1.0f / 600, 0f);
Log.d(TAG, "ScalingRunnable --> f2 = " + offset);
iv_img.setScaleY(offset);
iv_img.setScaleX(offset);
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/llf"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ScrollingActivity">
<!--app:layout_behavior="com.vily.newscroll2.MyBehavior"-->
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:fitsSystemWindows="true"
app:elevation="0dp"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="200dp"
android:fitsSystemWindows="true"
app:elevation="0dp"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll"
>
<ImageView
android:id="@+id/iv_img"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:background="@mipmap/ic_launcher"/>
<!--app:toolbarId="@id/toolbar"-->
<!--<android.support.v7.widget.Toolbar-->
<!--android:id="@+id/toolbar"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="100dp"-->
<!--app:layout_collapseMode="pin"-->
<!--app:popupTheme="@style/AppTheme.PopupOverlay" />-->
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_recycle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="40dp"
android:clipToPadding="false"
android:background="#c3c3c3"
android:overScrollMode="never"
/>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
<!--<include layout="@layout/content_scrolling" />-->
<!--<android.support.v7.widget.RecyclerView-->
<!--android:id="@+id/rv_recycle"-->
<!--app:layout_behavior="@string/appbar_scrolling_view_behavior"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent">-->
<!--</android.support.v7.widget.RecyclerView>-->
<!--<android.support.design.widget.FloatingActionButton-->
<!--android:id="@+id/fab"-->
<!--android:layout_width="100dp"-->
<!--android:layout_height="40dp"-->
<!--app:layout_anchor="@id/app_bar"-->
<!--app:layout_anchorGravity="bottom|center"-->
<!--android:background="@mipmap/ic_launcher"-->
<!--app:layout_behavior="com.vily.newscroll2.MyBehavior"/>-->
</android.support.design.widget.CoordinatorLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#00c3c3c3"
android:text="sssssss" />
</FrameLayout>