How to identify if a view is scrollable view in Android? -



How to identify if a view is scrollable view in Android? -

i creating custom view. need parse parents till scrollable view. how can identify view scrollable view ?

one simple way :

while(view != null){ if(view.getparent() instanceof view) { view = (view) view.getparent(); } else{ view = null; } if(view instanceof listview){ scrollableparentview = view; break; } else if(view instanceof scrollview){ scrollableparentview = view; break; } else if(view instanceof gridview){ scrollableparentview = view; break; } else if(view instanceof horizontalscrollview){ scrollableparentview = view; break; } }`

with approach implementation fail if tomorrow new scrollable view android.

please suggest approach.

one more question : how can hear parent scrollview event in custom kid view?

thanks in advance.

to observe scrollable view can check if it's scrollable specific direction:

if (view.canscrollhorizontally(1)) { // scrollable right } else if (view.canscrollhorizontally(-1)) { // scrollable left } else if (view.canscrollvertically(1)) { // scrollable top } else if (view.canscrollvertically(-1)) { // scrollable bottom } else { // un-scrollable }

android view android-custom-view

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -