Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple scrollto not working
    text
    copied!<p>Hi i have a simple program which contain a simple scroll view like android default calculator.<br> When user scroll more than offset value i want to scroll that to complete right or left.<br> But that's not working.<br> When i use myh.scrollBy(max, 0); nothing really changes.</p> <p>Mainactivity </p> <pre><code>public class MainActivity extends Activity { int pos=0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final HorizontalScrollView myh= (HorizontalScrollView) findViewById(R.id.myhview); myh.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { int xpos= myh.getScrollX(); int max=640; if((xpos&gt;50 &amp;&amp; pos==0) || (pos==640 &amp;&amp; xpos&gt;590)){ pos=640; myh.scrollBy(max, 0); } if((xpos&lt;590 &amp;&amp; pos==640) || ( pos==0 &amp;&amp; xpos&lt;50) ){ pos=0; myh.scrollBy(0, 0); } return false; } }); } } </code></pre> <p>And xml is<br> </p> <pre><code>&lt;HorizontalScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="50dp" android:id="@+id/myhview" &gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" &gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a01_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a00_text" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/a02_text" /&gt; &lt;/LinearLayout&gt; &lt;/HorizontalScrollView&gt; &lt;/LinearLayout&gt; </code></pre>
 

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