Created
March 20, 2015 06:26
-
-
Save ishitcno1/a65014c284f8e040d70a to your computer and use it in GitHub Desktop.
custom scrollview touch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment