I have a problem. I have my own scrollview, but it doesn't work. The scrollbar appears, but when I try to use it doesn't work. I have tried a lot of things, but none work. The code is:
@SuppressLint("ClickableViewAccessibility") public class myScrollView extends ScrollView { private boolean enableScrolling = true; public boolean isEnableScrolling() { return enableScrolling; } public void setEnableScrolling(boolean enableScrolling) { this.enableScrolling = enableScrolling; } public myScrollView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public myScrollView(Context context, AttributeSet attrs) { super(context, attrs); } public myScrollView(Context context) { super(context); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (isEnableScrolling()) { return super.onInterceptTouchEvent(ev); } else { return false; } } @Override public boolean onTouchEvent(MotionEvent ev) { if (isEnableScrolling()) { return super.onInterceptTouchEvent(ev); } else { return false; } } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // TODO Auto-generated method stub super.onMeasure(widthMeasureSpec, heightMeasureSpec); setMeasuredDimension(getMeasuredWidth(), getMeasuredHeight()); } } Inside of this scroll, I have a relativeLayout and inside of this a View. In the View I draw some bitmaps. They number more than it can display the screen.
The XML is:
<com.edjume.myScrollView android:id="@+id/scroll_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/table"> <RelativeLayout android:id="@+id/table" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> </RelativeLayout> </com.edjume.myScrollView> And in the activity I use:
RelativeLayout ll = (RelativeLayout) findViewById(R.id.table); ll.addView(new Table(this)); And finally, in my View (Table) has a OnDraw() and a onTouchEvent(). In the onTouchEvent I use the options ACTION_DOWN, ACTION_MOVE and ACTION_UP.