I am creating a custom view which extends ScrollView
. In this view I need nested scrolling so, in my current approach, I'm actually extending android.support.v4.widget.NestedScrollView
to support older versions because attribute android:nestedScrollingEnabled="true"
for ScrollView is only available starting on API 21.
With the experiments I'm doing extending from one and the other, I would say that using NestedScrollView is less efficient. Then, I know that I can create two different custom views and let the client use one or the other with qualified layout resources directory.
But my question is: Is there a way to create a custom view which internally extends NestedScrollView if the device using it is running with an API < 21 BUT extends ScrollView with android:nestedScrollingEnabled="true"
when running it on API >= 21 ? I think that would be better but don't if it is possible or how to do it.