Advertisement
Guest User

Untitled

a guest
May 4th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import android.content.Context;
  2. import android.util.AttributeSet;
  3. import android.view.MotionEvent;
  4. import android.widget.ScrollView;
  5.  
  6. /**
  7. * Created by albert on 15-3-19.
  8. *
  9. * 可以设置是否捕获touch事件,解决当包含其它可滚动组件时冲突的问题
  10. *
  11. */
  12. public class CustomScrollView extends ScrollView {
  13. private boolean mScrollable = true;
  14.  
  15. public CustomScrollView(Context context) {
  16. this(context, null, 0);
  17. }
  18.  
  19. public CustomScrollView(Context context, AttributeSet attrs) {
  20. this(context, attrs, 0);
  21. }
  22.  
  23. public CustomScrollView(Context context, AttributeSet attrs, int defStyle) {
  24. super(context, attrs, defStyle);
  25. }
  26.  
  27. @Override
  28. public boolean onInterceptTouchEvent(MotionEvent ev) {
  29. if (mScrollable) {
  30. return super.onInterceptTouchEvent(ev);
  31. } else {
  32. return false;
  33. }
  34. }
  35.  
  36. /**
  37. * 设置是否可滚动
  38. *
  39. * @param scrollable
  40. */
  41. public void setScrollable(boolean scrollable) {
  42. mScrollable = scrollable;
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement