代码拉取完成,页面将自动刷新
粘性ScrollView滚动到顶部指定子View悬浮顶部
Android开发中这样的需求比较多,之前需要写两份布局检测距离后切换展示,比较麻烦且臃肿,使用这个控件只需要把悬浮的控件打个tag即可实现,希望对你有多帮助,有什么好的意见也请多多提出!
图片滑动效果 :
buildscript {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
...
implementation 'com.gitee.zhaolonglongmayday:sticky-scroll-view:v1.1.1'
}
<cn.com.jmw.mylibrary.StickyScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#B55D52" />
<View
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#366DF1" />
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@color/white"
android:gravity="center"
android:tag="sticky"
android:text="我是悬浮标题" />
<View
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#A8A8A8" />
<View
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#ACACAC" />
<View
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#D7BB80" />
<View
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#ff3737" />
<View
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#E44B46" />
</LinearLayout>
</cn.com.jmw.mylibrary.StickyScrollView>
需要悬浮的控件添加的tag android:tag="sticky
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。