Skip to content

Android module - Fragment added but not appear #26963

Closed
@rener172846

Description

@rener172846

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Issue TemplateThis issue does not make use of the Issue Template, and may be missing necessary information.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions