Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.content.Context;
- import android.util.AttributeSet;
- import android.view.MotionEvent;
- import android.widget.ScrollView;
- /**
- * Created by albert on 15-3-19.
- *
- * 可以设置是否捕获touch事件,解决当包含其它可滚动组件时冲突的问题
- *
- */
- public class CustomScrollView extends ScrollView {
- private boolean mScrollable = true;
- public CustomScrollView(Context context) {
- this(context, null, 0);
- }
- public CustomScrollView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
- public CustomScrollView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
- @Override
- public boolean onInterceptTouchEvent(MotionEvent ev) {
- if (mScrollable) {
- return super.onInterceptTouchEvent(ev);
- } else {
- return false;
- }
- }
- /**
- * 设置是否可滚动
- *
- * @param scrollable
- */
- public void setScrollable(boolean scrollable) {
- mScrollable = scrollable;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement