Reputation: 1211
I have followed the RN docs to create an Android Native Fragment: https://reactnative.dev/docs/native-components-android#1-create-a-fragment
The Fragment is loaded, I can see it in the Layout Inspector, however as you can see in the screenshot, it is in the very bottom of the Views and I'm assuming that's the reason why I can't see the TextView that I have inside of the Fragment.
So, what does it need to be done do to bring the CustomView to the Front?
I've tried calling: myFragment.customView.bringToFront();
but didn't work.
The commit() always returns -1:
activity.getSupportFragmentManager()
.beginTransaction()
.add(reactNativeViewId, myFragment, String.valueOf(reactNativeViewId))
.commit();
I've followed the article, went back and forth into the instructions and everything is there.
I have created a repo to help debug the issue: https://github.com/wilsolutions/react-native-experiments
Any thoughts?
Thank you
Upvotes: 1
Views: 1015
Reputation: 1251
I wrote that part of the documentation. I added the missing parts (and also fixed an issue that caused layout to be unpredictable) in this PR:
https://github.com/facebook/react-native-website/pull/2599. Please let me know if you still miss something.
Answer wrapped up basically:
setupLayout
methodViewGroup parentView = (ViewGroup) root.findViewById(reactNativeViewId).getParent();
should be
ViewGroup parentView = (ViewGroup) root.findViewById(reactNativeViewId);
Upvotes: 3