当前位置:网站首页>Live source code, floating window rolling gradient effect
Live source code, floating window rolling gradient effect
2022-06-11 12:04:00 【Yunbao network technology】
Live source , Suspension window rolling gradient effect to achieve the relevant code
Customize first ScrollView
MyScrollView
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;
/** * @Author:Administrator * @E-mail: [email protected] * @Date:2020/8/6 9:43 * @Description: Description information */
public class MyScrollView extends ScrollView {
private OnScrollListener onScrollListener; public MyScrollView(Context context) {
this(context, null);
}
public MyScrollView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public MyScrollView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public void setOnScrollListener(OnScrollListener onScrollListener) {
this.onScrollListener = onScrollListener;
}
@Override protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt); if (onScrollListener != null) {
onScrollListener.onScroll(t);
}
}
public interface OnScrollListener {
public void onScroll(int scrollY);
}
}
Use... In layout MyScrollView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.utils.MyScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<View
android:id="@+id/imageview"
android:layout_width="match_parent"
android:layout_height="500dp"
android:background="@android:color/holo_blue_dark" />
<!-- Displayed when sliding title( Internal fixation view)-->
<LinearLayout
android:id="@+id/ll_filter"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#00EAFF"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1000dp"
android:background="@android:color/holo_green_light" />
<View
android:layout_width="match_parent"
android:layout_height="500dp"
android:background="#f00" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
</LinearLayout>
<!-- Shown on top after sliding title( External fixation view)-->
<LinearLayout
android:id="@+id/ll_top"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#FF0000"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=" External fixation View" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_home_title"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_50"
android:layout_centerHorizontal="true"
android:layout_marginLeft="@dimen/dp_24"
android:layout_marginTop="@dimen/dp_12"
>
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
</FrameLayout>
</com.utils.MyScrollView>
</LinearLayout>
kotlin
First write ScrollView monitor
scrollView.setOnScrollListener(this)
Color gradient , obtain imageview To set the gradient
override fun onScroll(scrollY: Int) {
val mTop = scrollY.coerceAtLeast(ll_filter.top)
ll_top.layout(0, mTop, ll_top.width, mTop + ll_top.height)
/* * Color gradient ( You can delete the following without gradient ) * */
var imageHeight = imageview.getHeight() if (scrollY <= imageHeight) {
val scale: Float = scrollY.toFloat() / imageHeight
val alpha = 255 * scale
// It's just layout The background is transparent ( Imitates the sliding effect ) White transparent
ll_top.setBackgroundColor(Color.argb(alpha.toInt(), 255, 255, 255))
// Set the text color , black , Increase transparency
//textView.setTextColor(Color.argb(alpha.toInt(), 0, 0, 0))
Log.e("111", "y > 0 && y <= imageHeight")
}
}
That's all Live source , Suspension window rolling gradient effect to achieve the relevant code , More content welcome to follow the article
边栏推荐
- When the security engineer finds a major vulnerability in the PS host, the CD can execute arbitrary code in the system
- 【LeetCode】494. Objective and (2 wrong questions)
- 大数相加(C语言)
- Qt中radioButton使用
- MYCAT sub database and sub table
- [file upload vulnerability 06] server file content detection and bypass experiment + image horse production method (based on upload-labs-14 shooting range)
- Notes on topic brushing (XIV) -- binary tree: sequence traversal and DFS, BFS
- Intermediate web development engineer, interview questions + Notes + project practice
- 让你搞懂冒泡排序(C语言)
- Zero after factorial (C language)
猜你喜欢

C# 在PDF文档中应用多种不同字体

How to solve the problem that high-precision positioning technologies such as ultra wideband UWB, Bluetooth AOA and RTK cannot be widely used due to their high cost? Adopt the idea of integrated deplo

Let you understand bubble sorting (C language)

JS to realize the rotation chart (riding light). Pictures can be switched left and right. Moving the mouse will stop the rotation

深度学习与CV教程(14) | 图像分割 (FCN,SegNet,U-Net,PSPNet,DeepLab,RefineNet)

让你搞懂冒泡排序(C语言)

吊打面试官,涨姿势

Let you understand selection sorting (C language)
![[JUC supplementary] immutable object, shared meta mode, final principle](/img/c1/c29229108a3f66b83d13b4d90d49f7.jpg)
[JUC supplementary] immutable object, shared meta mode, final principle

.net core 抛异常对性能影响的求证之路
随机推荐
Hamiltonian graph
Runtime reconfiguration of etcd
iframe 传值
MYCAT sub database and sub table
Zhouhongyi's speech at the China Network Security Annual Conference: 360 secure brain builds a data security system
Smart sidebar plug-in: Mo widgets
JVM class loading process
golang利用异或^交换两个变量以及加解密
苹果MobileOne: 移动端仅需1ms的高性能骨干
Let you understand selection sorting (C language)
Merge two ordered arrays (C language)
C# 设置或验证 PDF中的文本域格式
Use compiler option '--downleveliteration' to allow iteration of iterations
PS does not display text cursor, text box, and does not highlight after selection
Hang up the interviewer
Dominating set, independent set, covering set
Elk - elastalert largest pit
Learning in Bi design 03
Is the SSL certificate reliable in ensuring the information security of the website?
JS interview questions - arrow function, find and filter some and every