android - React Native ViewPagerAndroid with multiple visible pages -


i've been trying use viewpagerandroid show carousel "stops" @ each item so:

carousel

it appears react-native-carousel , react-native-swiper don't support these features yet on android. have native viewpager need do, i'm having problems incorporating react native environment.

the native component carouselcontainer uses layout.xml , expects viewpager subcomponent.

     <com.mycompany.ui.carouselcontainer         android:id="@+id/pager_container"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_margintop="10dp">          <android.support.v4.view.viewpager             android:id="@+id/viewpager"             android:layout_width="190dp"             android:layout_height="280dp"             android:layout_gravity="center_horizontal" />      </com.mycompany.ui.carouselcontainer > 

carouselcontainer framelayout subclass gets ref viewpager in onfinishinflate method. calls setpagemargin on viewpager , setclipchildren(false) render multiple viewpager pages on screen @ same time.

i took @ viewpagerandroid implementation, , looks it's viewpager set reactviewpagermanager. reactviewpagermanager exposes viewpager's child views via viewgroupmanager interface.

so copied reactviewpagermanager in own carouselviewpagermanager , reactviewpager carouselviewpager.

the 1 thing new here carouselviewpagercontainer. manager creates container , container creates view pager instead of manager creating view pager directly. since there's no layout xml container instantiates pager directly instead of getting onfinishinflate.

for reason, i'm getting nothing rendered on screen when use it. think it's due having carouselviewpagercontainer view in between i'm not sure begin. need mess layoutshadownode? need add carouselviewpager list of child views returned manager?

the native ui components documentation mentions simpleviewmanager. :(

// copy of reactviewpagermanager public class carouselviewpagermanager extends viewgroupmanager<carouselviewpagercontainer> {      @override     protected carouselviewpagercontainer createviewinstance(themedreactcontext reactcontext) {         return new carouselviewpagercontainer(reactcontext);     }      // ...      @override     public void addview(carouselviewpagercontainer parent, view child, int index) {         parent.addviewtoadapter(child, index);     }      @override     public int getchildcount(carouselviewpagercontainer parent) {         // should carouselviewpager counted?         return parent.getviewcountinadapter();     }      @override     public view getchildat(carouselviewpagercontainer parent, int index) {         return parent.getviewfromadapter(index);     }      @override     public void removeviewat(carouselviewpagercontainer parent, int index) {         parent.removeviewfromadapter(index);     }  }   public class carouselviewpagercontainer extends framelayout implements viewpager.onpagechangelistener {      private final carouselviewpager mpager; // copy of reactviewpager      public carouselviewpagercontainer(reactcontext context) {         mpager = new carouselviewpager(context);     }      // ...      // pass through carouselviewpager     public void setcurrentitemfromjs(int item, boolean animated) {         mpager.setcurrentitemfromjs(item, animated);     }      /*package*/ void addviewtoadapter(view child, int index) {         mpager.addviewtoadapter(child, index);     }      /*package*/ void removeviewfromadapter(int index) {         mpager.removeviewfromadapter(index);     }      /*package*/ int getviewcountinadapter() {         return mpager.getviewcountinadapter();     }      /*package*/ view getviewfromadapter(int index) {         return mpager.getviewfromadapter(index);     } } 

if know of simpler way tackle problem i'm ears!

i mean thing i'm using framelayout container center first viewpager page , occupy space multiple pages show. :/

it's been such struggle :(


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -