SyncHorizontalScrollView.java
884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.lijinji.call.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.HorizontalScrollView;
/**
* @Description: 可联动horizontalscrollview
*/
public class SyncHorizontalScrollView extends HorizontalScrollView {
private View mView;
public SyncHorizontalScrollView(Context context) {
super(context);
}
public SyncHorizontalScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
//设置控件滚动监听,得到滚动的距离,然后让传进来的view也设置相同的滚动具体
if(mView!=null) {
mView.scrollTo(l, t);
}
}
/**
* 设置跟它联动的view
* @param view
*/
public void setScrollView(View view) {
mView = view;
}
}