Remove scroll bar track from ScrollView in Android
To remove a scrollbar from a view (and its subclass) via xml: android:scrollbars=”none” http://developer.android.com/reference/android/view/View.html#attr_android:scrollbars
To remove a scrollbar from a view (and its subclass) via xml: android:scrollbars=”none” http://developer.android.com/reference/android/view/View.html#attr_android:scrollbars
I had the same issue and finally figured it out. This is for a vertical ScrollView. Put your ScrollView inside a RelativeLayout and center it in the RelativeLayout. In order for this to work, your ScrollView should have android:layout_height=”wrap_content” This is how the final code should look like: <?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent”> … Read more
The recommended way from Apple is to change the contentInset of the UIScrollView. It is a very elegant solution, because you do not have to mess with the contentSize. Following code is copied from the Keyboard Programming Guide, where the handling of this issue is explained. You should have a look into it. // Call … Read more
Solution: ((ViewGroup)scrollChildLayout.getParent()).removeView(scrollChildLayout); //scrollView.removeView(scrollChildLayout); Use the child element to get a reference to the parent. Cast the parent to a ViewGroup so that you get access to the removeView method and use that. Thanks to @Dongshengcn for the solution
Mixing some of the suggestions above, and was able to get a good solution: Custom ScrollView: package com.scrollable.view; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.ScrollView; public class VScroll extends ScrollView { public VScroll(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public VScroll(Context context, AttributeSet attrs) { super(context, attrs); } public VScroll(Context … Read more
The answer from Pragna does not work always, try this: mScrollView.post(new Runnable() { public void run() { mScrollView.scrollTo(0, mScrollView.getBottom()); } }); or mScrollView.post(new Runnable() { public void run() { mScrollView.fullScroll(mScrollView.FOCUS_DOWN); } }); if You want to scroll to start mScrollView.post(new Runnable() { public void run() { mScrollView.fullScroll(mScrollView.FOCUS_UP); } });
Every instance of View calls getViewTreeObserver(). Now when holding an instance of ViewTreeObserver, you can add an OnScrollChangedListener() to it using the method addOnScrollChangedListener(). You can see more information about this class here. It lets you be aware of every scrolling event – but without the coordinates. You can get them by using getScrollY() or … Read more
I found a solution that works excellently and can scroll the ListView without problems: ListView lv = (ListView)findViewById(R.id.myListView); // your listview inside scrollview lv.setOnTouchListener(new ListView.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: // Disallow ScrollView to intercept touch events. v.getParent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: // … Read more
Try adding android:fillViewport=”true”to your ScrollView remember that android:layout_height=”fill_parent” means “set the height to the height of the parent.” This is obviously not what you want when using a ScrollView. After all, the ScrollView would become useless if its content was always as tall as itself. To work around this, you need to use the ScrollView … Read more
Try mainScrollView.fullScroll(ScrollView.FOCUS_UP); it should work.