软件编程
位置:首页>> 软件编程>> Android编程>> Android仿京东搜索框渐变效果

Android仿京东搜索框渐变效果

作者:AND_Devil  发布时间:2022-09-08 19:57:05 

标签:Android,京东,搜索框

在许多APP中,有的搜索框是一直固定的,有的呢,附加了很多的效果,就比如京东

Android仿京东搜索框渐变效果

好吧,谁让京东那么厉害呢,不说了,开始 * !

原理:就是自定义scrollview实现对滑动高度的监听而已,如此实现对搜索框的渐变

先贴上我的自定义scrollview


//自定义ScrollView
public class CustomView extends ScrollView {

public interface ScrollViewListener {
void onScrollChanged(CustomView customView, int x, int y, int oldx, int oldy);
}

private ScrollViewListener scrollViewListener = null;

public CustomView(Context context) {
super(context);
}

public CustomView(Context context, AttributeSet attrs,
  int defStyle) {
super(context, attrs, defStyle);
}

public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
}

public void setScrollViewListener(ScrollViewListener scrollViewListener) {
this.scrollViewListener = scrollViewListener;
}

@Override
protected void onScrollChanged(int x, int y, int oldx, int oldy) {
super.onScrollChanged(x, y, oldx, oldy);
if (scrollViewListener != null) {
 scrollViewListener.onScrollChanged(this, x, y, oldx, oldy);
}
}
}

来源:https://blog.csdn.net/qq_40543575/article/details/79666499

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com