Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>there is another way. moddified <strong>HorizontalScrollView</strong> as a wrapper for <strong>ScrollView</strong>. normal <strong>HorizontalScrollView</strong> when catch touch events don't forward them to <strong>ScrollView</strong> and you only can scroll one way at time. here is solution:</p> <pre><code>package your.package; import android.widget.HorizontalScrollView; import android.widget.ScrollView; import android.view.MotionEvent; import android.content.Context; import android.util.AttributeSet; public class WScrollView extends HorizontalScrollView { public ScrollView sv; public WScrollView(Context context) { super(context); } public WScrollView(Context context, AttributeSet attrs) { super(context, attrs); } public WScrollView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public boolean onTouchEvent(MotionEvent event) { boolean ret = super.onTouchEvent(event); ret = ret | sv.onTouchEvent(event); return ret; } @Override public boolean onInterceptTouchEvent(MotionEvent event) { boolean ret = super.onInterceptTouchEvent(event); ret = ret | sv.onInterceptTouchEvent(event); return ret; } } </code></pre> <p>using:</p> <pre><code> @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*BIDIRECTIONAL SCROLLVIEW*/ ScrollView sv = new ScrollView(this); WScrollView hsv = new WScrollView(this); hsv.sv = sv; /*END OF BIDIRECTIONAL SCROLLVIEW*/ RelativeLayout rl = new RelativeLayout(this); rl.setBackgroundColor(0xFF0000FF); sv.addView(rl, new LayoutParams(500, 500)); hsv.addView(sv, new LayoutParams(WRAP_CONTENT, MATCH_PARENT /*or FILL_PARENT if API &lt; 8*/)); setContentView(hsv); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload