From f361b4e5c3e71d5c3444bba955410cb2b1431e72 Mon Sep 17 00:00:00 2001 From: lijian Date: Mon, 20 Apr 2020 15:25:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E5=90=B8=E9=A1=B6view?= =?UTF-8?q?=E5=B8=B8=E9=A9=BB=E9=85=8D=E7=BD=AE=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 3 +- .../consecutivescrollerdemo/MainActivity.java | 7 + .../PermanentStickyActivity.java | 50 +++++++ app/src/main/res/layout/activity_main.xml | 5 + .../res/layout/activity_sticky_permanent.xml | 135 ++++++++++++++++++ .../ConsecutiveScrollerLayout.java | 82 ++++++++--- .../src/main/res/values/attrs.xml | 3 + 7 files changed, 261 insertions(+), 24 deletions(-) create mode 100644 app/src/main/java/com/donkingliang/consecutivescrollerdemo/PermanentStickyActivity.java create mode 100644 app/src/main/res/layout/activity_sticky_permanent.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 626284f..6f83bb2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,10 +11,11 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - + + diff --git a/app/src/main/java/com/donkingliang/consecutivescrollerdemo/MainActivity.java b/app/src/main/java/com/donkingliang/consecutivescrollerdemo/MainActivity.java index 188e376..de3380e 100644 --- a/app/src/main/java/com/donkingliang/consecutivescrollerdemo/MainActivity.java +++ b/app/src/main/java/com/donkingliang/consecutivescrollerdemo/MainActivity.java @@ -44,6 +44,13 @@ public void onClick(View v) { startActivity(intent); } }); + findViewById(R.id.sticky_permanent).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(MainActivity.this, PermanentStickyActivity.class); + startActivity(intent); + } + }); } diff --git a/app/src/main/java/com/donkingliang/consecutivescrollerdemo/PermanentStickyActivity.java b/app/src/main/java/com/donkingliang/consecutivescrollerdemo/PermanentStickyActivity.java new file mode 100644 index 0000000..b5fd6e0 --- /dev/null +++ b/app/src/main/java/com/donkingliang/consecutivescrollerdemo/PermanentStickyActivity.java @@ -0,0 +1,50 @@ +package com.donkingliang.consecutivescrollerdemo; + +import android.os.Bundle; +import android.webkit.WebChromeClient; +import android.webkit.WebView; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.donkingliang.consecutivescroller.ConsecutiveScrollerLayout; +import com.donkingliang.consecutivescrollerdemo.adapter.RecyclerViewAdapter; + +public class PermanentStickyActivity extends AppCompatActivity { + + private ConsecutiveScrollerLayout scrollerLayout; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_sticky_permanent); + + scrollerLayout = findViewById(R.id.scrollerLayout); + + WebView webView = findViewById(R.id.webView); + webView.loadUrl("https://github.com/donkingliang"); + + webView.setWebChromeClient(new WebChromeClient() { + @Override + public void onProgressChanged(WebView view, int newProgress) { + super.onProgressChanged(view, newProgress); + // 在webView加载的过程中,用户滚动了webView内容,可能会使webView的显示与scrollerLayout断层, + // 需要让scrollerLayout重新检查一下所有View的显示位置 + scrollerLayout.checkLayoutChange(); + } + }); + + + RecyclerView recyclerView1 = findViewById(R.id.recyclerView1); + recyclerView1.setLayoutManager(new LinearLayoutManager(this)); + RecyclerViewAdapter adapter1 = new RecyclerViewAdapter(this,"RecyclerView1-"); + recyclerView1.setAdapter(adapter1); + + RecyclerView recyclerView2 = findViewById(R.id.recyclerView2); + recyclerView2.setLayoutManager(new LinearLayoutManager(this)); + RecyclerViewAdapter adapter2 = new RecyclerViewAdapter(this,"RecyclerView2-"); + recyclerView2.setAdapter(adapter2); + + } +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 274857d..0398ce0 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -29,5 +29,10 @@ android:layout_height="wrap_content" android:text="支持ViewPager" android:textAllCaps="false" /> +