Note that there are some explanatory texts on larger screens.

plurals
  1. POsmoothScroll method not working in onCreate()
    text
    copied!<p>I have created a custom scroll view and added some images views dynamically to it. All I wanted to do is to scroll the scrollview to a particular position when the view is initialized. I used scrollview.smoothScrollTo() method to move the scrollview to particular position. It is working perfectly in Android 2.1 but when in android 2.2 it is not working. The scrollview always goes to the initial position. Whwn I used the same method in OnClick Listener of a button it is working. Please help.</p> <pre><code> protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.galleryitem_details); hscrollView = (HorizontalScrollView)findViewById(R.id.photolist_scrollview); addImages(); hscrollView.smoothScrollTo(1000, 0); } private void addImages() { for(int i = 0; i&lt; 10; i++) { View imageDetailView = View.inflate(this, R.layout.gallery_image, null); ImageView image = (ImageView)imageDetailView.findViewById(R.id.gallery_imagebig); TextView txtView = (TextView)imageDetailView.findViewById(R.id.imageBigText); ProgressBar spinner = (ProgressBar)imageDetailView.findViewById(R.id.gallery_scrollimage); txtView.setWidth(screenWidth); imageDetailView.setBackGroundResource(R.drawable.icon); txtView.setText(PHGalleryActivity.galleryImages.get(i).getImageCaption()); imageDetailLayout.addView(imageDetailView); } /* * Set the position of scroll view. */ } </code></pre> <p>the hscrollview is not scrolled to the position. The scrollview starts from initial postion. </p>
 

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