Closed
Description
I have a specific Android native map library and going to integrate that in a React Native project. The library provides the Fragment
with the all it features. I tried to make framelayout and add that libraries fragment in it. It seems all functions are applied without any exceptions but the map view isn't appear with size 0.
Following is the replacement codes:
public class MapView extends FrameLayout {
private MapFragment m_mapFragment;
private AppCompatActivity m_activity;
...
public MapView(AppCompatActivity context) {
super(context);
m_activity = context;
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT
);
this.setLayoutParams(params);
}
public void init() {
FragmentManager fragmentManager = m_activity.getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
m_mapFragment = new MapFragment();
fragmentTransaction.add(this.getId(), m_mapFragment);
fragmentTransaction.commitNow();
View view = m_mapFragment.getView();
if (view != null) {
LayoutParams parmas = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
view.setLayoutParams(parmas);
view.setBackgroundColor(Color.GREEN);
}
}
...
}
As I debugged when init
function is called, the MapView(FrameLayout) has 1080 width as well but mapFragment
isn't still shown either map nor green color.