Adding a Fragment to a View

I am writing an Android plugin for Unity. I am using some existing code that I have to adhere to.

This existing code uses a Fragment for the user interface portion.

Can someone tell me how to get the UnityPlayer main view so that I can add this fragment to the ViewGroup?

Example code would be awesome!

I figured out the main part of this. I use the following code:

		ViewGroup rootView = (ViewGroup)UnityPlayer.currentActivity.findViewById(android.R.id.content);
		        
                // find the first leaf view (i.e. a view without children)
                // the leaf view represents the topmost view in the view stack
                View topMostView = getLeafView(rootView);
                
                if (topMostView != null) {
                	
	                // let's add a sibling to the leaf view
	                ViewGroup leafParent = (ViewGroup)topMostView.getParent();
			    
	                if (leafParent != null) {
	                	leafParent.setId(0x20348);

						WebViewFragment fragment = new WebViewFragment();
					    FragmentManager fragmentManager = UnityPlayer.currentActivity.getFragmentManager();
					    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
					    fragmentTransaction.add(leafParent.getId(), fragment);
					    fragmentTransaction.commit();
                        }
                 }

getLeafView is the following code:

    private View getLeafView(View view) {
        if (view instanceof ViewGroup) {
            ViewGroup vg = (ViewGroup)view;
            for (int i = 0; i < vg.getChildCount(); ++i) {
                View chview = vg.getChildAt(i);
                View result = getLeafView(chview);
                if (result != null) 
                    return result;
            }
            return null;
        }
        else {
            return view;
        }
    }

Thanks to a google search and a posting about finding the UnityPlayer view like that.

I have another question now. The above code puts the WebViewFragment full screen covering the whole Unity view. How would I go about making it so that the Fragment only takes up part of the screen showing the Unity background through?