_From @manijak on October 31, 2016 18:36_
Yes.
Tried at first on the "next" versions of core-modules. But managed to get the same result on 2.3.0.
I'm trying to add the android version to my Carousel plugin. Playing with the ViewPager and Layouts. If I return the ViewPager as _nativeView it works fine, but if I return the RelativeLayout as the _nativeView it fails.
java.lang.ClassCastException: android.support.v4.view.ViewPager$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:476)
at android.view.View.measure(View.java:18788)
at org.nativescript.widgets.CommonLayoutParams.measureChild(CommonLayoutParams.java:229)
at org.nativescript.widgets.StackLayout.onMeasure(StackLayout.java:83)
at android.view.View.measure(View.java:18788)
at org.nativescript.widgets.CommonLayoutParams.measureChild(CommonLayoutParams.java:229)
at org.nativescript.widgets.MeasureHelper.measureChildFixedColumnsAndRows(GridLayout.java:1059)
at org.nativescript.widgets.MeasureHelper.measure(GridLayout.java:869)
at org.nativescript.widgets.GridLayout.onMeasure(GridLayout.java:279)
at android.view.View.measure(View.java:18788)
at org.nativescript.widgets.CommonLayoutParams.measureChild(CommonLayoutParams.java:229)
at org.nativescript.widgets.ContentLayout.onMeasure(ContentLayout.java:32)
...
Android
Here is a sample app that will reproduce the issue (android only)
https://dl.dropboxusercontent.com/u/33168380/pager-test.zip
_Copied from original issue: NativeScript/NativeScript#3001_
@manijak You could try getting rid of the RelativeLayout and adding views (CarouselItems) only to the ViewPager as that will help simplify logic.
Yeah you are correct, I have moved away from the RelativeLayout idea altogether. The only reason I decided to wrap ViewPager innside the RelativeLayout is because I wanted to present the pageIndicator on top of the viewpager (like an overlay). From the examples online, relativeLayout was recomended.
The {N} TabView does something similar with the GridLayout. Packing a viewPager and TabStrip.
If I only add the indicator to the relativeLayout, it worked, but if I add the viewPager, it didn't.
So my solution (not a very good one), is to add the indicator to the parent view of the viewPager. Wrapping this plugin in a GridLayout in the xml, makes it work (indicator overlays viewPager, otherwise it's added below).
I've also managed to get it working innside a TabView (they both extend ViewPager).
@Pip3r4o Thanks for the time you took to look at this. 馃憤 Think we can close this one.
Most helpful comment
Yeah you are correct, I have moved away from the RelativeLayout idea altogether. The only reason I decided to wrap ViewPager innside the RelativeLayout is because I wanted to present the pageIndicator on top of the viewpager (like an overlay). From the examples online, relativeLayout was recomended.
The {N} TabView does something similar with the GridLayout. Packing a viewPager and TabStrip.
If I only add the indicator to the relativeLayout, it worked, but if I add the viewPager, it didn't.
So my solution (not a very good one), is to add the indicator to the parent view of the viewPager. Wrapping this plugin in a GridLayout in the xml, makes it work (indicator overlays viewPager, otherwise it's added below).
I've also managed to get it working innside a TabView (they both extend ViewPager).
@Pip3r4o Thanks for the time you took to look at this. 馃憤 Think we can close this one.