How can you tell if a View is visible on screen in Android?

This code works for me: public static boolean isVisible(final View view) { if (view == null) { return false; } if (!view.isShown()) { return false; } final Rect actualPosition = new Rect(); view.getGlobalVisibleRect(actualPosition); final Rect screen = new Rect(0, 0, getScreenWidth(), getScreenHeight()); return actualPosition.intersect(screen); }

How can I make my layout scroll both horizontally and vertically?

I was able to find a simple way to achieve both scrolling behaviors. Here is the xml for it: <ScrollView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:scrollbars=”vertical”> <HorizontalScrollView android:layout_width=”320px” android:layout_height=”fill_parent”> <TableLayout android:id=”@+id/linlay” android:layout_width=”320px” android:layout_height=”fill_parent” android:stretchColumns=”1″ android:background=”#000000″/> </HorizontalScrollView> </ScrollView>

Hide scrollbar in ScrollView

In Java add this code: myScrollView.setVerticalScrollBarEnabled(false); myScrollView.setHorizontalScrollBarEnabled(false); In XML add following attribute to your ScrollView: android:scrollbars=”none” Like this: <ScrollView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:id=”@+id/mainScroll” android:scrollbars=”none” <!– line to be added –> >

Detect end of ScrollView

Did it! Aside of the fix Alexandre kindly provide me, I had to create an Interface: public interface ScrollViewListener { void onScrollChanged(ScrollViewExt scrollView, int x, int y, int oldx, int oldy); } Then, i had to override the OnScrollChanged method from ScrollView in my ScrollViewExt: public class ScrollViewExt extends ScrollView { private ScrollViewListener scrollViewListener = … Read more

Recyclerview Changing Items During Scroll

Please try this If you are using ListView – override the following methods. @Override public int getViewTypeCount() { return getCount(); } @Override public int getItemViewType(int position) { return position; } If you are using RecyclerView – override only getItemViewType() method. @Override public int getItemViewType(int position) { return position; }

How to prevent a scrollview from scrolling to a webview after data is loaded?

I had the same problem, after hours of trying several ideas, what finally worked for me was simply adding the descendantFocusability attribute to the ScrollView’s containing LinearLayout, with the value blocksDescendants. In your case: <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”vertical” android:descendantFocusability=”blocksDescendants” > Haven’t had the problem reoccur since.