Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make horizontal scrolling view in android
    primarykey
    data
    text
    <p>I Want to make this type of horizontal scrolling , look at pictures</p> <p><img src="https://i.stack.imgur.com/5l7Ps.jpg" alt="enter image description here"> >>>><strong>............................................</strong><img src="https://i.stack.imgur.com/qKen0.jpg" alt="enter image description here"></p> <p><strong>XML file saved at res/layout/main.xml:</strong> Am i right my main.xml file has worng? I want to use . </p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="200dp"&gt; &lt;/ImageView&gt; &lt;TextView android:text="Zoo" android:id="@+id/PicDescription" android:layout_width="wrap_content" android:textSize="40sp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="10dp"&gt;&lt;/TextView&gt; &lt;TextView android:text="Z" android:id="@+id/captitalText" android:layout_height="wrap_content" android:layout_gravity="center" android:textSize="100sp" android:layout_width="wrap_content" android:layout_marginTop="25dp"&gt;&lt;/TextView&gt; </code></pre> <p></p> <p><strong>XML file saved at res/values/letters.xml:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; resources&gt; &lt;string-array name="desc"&gt; &lt;item&gt;Apple&lt;/item&gt; &lt;item&gt;Ball&lt;/item&gt; ... &lt;item&gt;Zoo&lt;/item&gt; &lt;/string-array&gt; &lt;string-array name="capitalLetter"&gt; &lt;item&gt;A&lt;/item&gt; &lt;item&gt;B&lt;/item&gt; ... &lt;item&gt;Z&lt;/item&gt; &lt;/string-array&gt; </code></pre> <p></p> <p>What is the code of that Horizontal scrolling action in android. Please give advice, I am the new of the android, I totally confused of that scrolling. I follow this <a href="https://stackoverflow.com/questions/5102993/swipe-fling-tab-changing-in-conjunction-with-scrollview">link1</a> <a href="https://stackoverflow.com/questions/3171452/scrollview-and-gallery-interfering">link2</a> but could not get any idea. Thanks in advance and hope you can solve this.</p> <p><strong>Edit : Sep 11</strong></p> <p>Here is my code.It out is when I try to scrolling then change B, when complete scrolling the page the again A becomes. I think, I call when scrolling is complete starting value, am i right?</p> <p>Give me suggestion what can i do for fix this code.</p> <pre><code> public class Test extends Activity { private static final int SWIPE_MIN_DISTANCE = 120; private static final int SWIPE_MAX_OFF_PATH = 250; private static final int SWIPE_THRESHOLD_VELOCITY = 200; private GestureDetector gestureDetector; String[] big; TextView txtbig; int count=0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); big = getResources().getStringArray(R.array.capitalLetter); gestureDetector = new GestureDetector(new MyGestureDetector()); View mainview = (View) findViewById(R.id.mainView); mainview.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (gestureDetector.onTouchEvent(event)) { textChange(); return true; } return false; } }); //textChange(); } private void textChange() { txtbig = (TextView) findViewById(R.id.bigText); String bigTextString=big[count]; txtbig.setText(bigTextString); count++; if(count==big.length) { count=0; } } class MyGestureDetector extends SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { Intent intent = new Intent(Test.this.getBaseContext(),Test.class); //textChange(); if (Math.abs(e1.getY() - e2.getY()) &gt; SWIPE_MAX_OFF_PATH) { //textChange(); return false; } // right to left swipe if (e1.getX() - e2.getX() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) { textChange(); startActivity(intent); Test.this.overridePendingTransition( R.anim.slide_in_right, R.anim.slide_out_left); return true; // right to left swipe } else if (e2.getX() - e1.getX() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) { // startActivity(intent); // textChange(); Test.this.overridePendingTransition( R.anim.slide_in_left, R.anim.slide_out_right); } return false; } @Override public boolean onDown(MotionEvent e) { return true; } } </code></pre> <p>}</p>
    singulars
    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.
 

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