I believe I have a fundamental problem as I have worked on it for days.
Objective: Add a Android EditText View to the bottom of my UnityPlayer activity by creating a Java Plugin. I need to do this because I will be using Android IME (voice) functionality in conjunction with the edittext view.
Strategy (See Code Comments): I created a Unity Java plugin that is primiraly composed of the "addEditTextView" Method below. Then in unity I have a GUI button to call "addEditTextView" Method. As expected the EditText view shows up at the bottom of the screen when the button is touched.
Problem: When I touch the edittext view is gets covered by the softkeyboard instead of moving upward. Note the UnityActivity content added by unity does pan/move upward as expected.
-I create a standalone Android Eclipse project with a basic activity. I then implemented this exact function again and it worked (Edittext stayed just above the softkeyboard). This leads me to believe that the Unity Activity is different in some way than my experimental standalone basic activity.
-I made the EditText box really tall (ie. 200). The softkeyboard covered the bottom half, which showed it is visible but not moving.
-I tried centering the textedit with "CENTER_IN_PARENT" (below) to see if I could learn something. It worked in the standalone Android project, but the edittext remained at the top for the unity project. Why - This is really confusing?
final Activity _unityActivity; // Assign to the UnityPlayerActivy in contructor
final Context _context; // Assign to the Unity Context in consturctor
public void addEditTextView()
public void run()
// Create LayoutParams that will place EditText at bottom of parent RelativeLayout (ie. ALIGN_PARENT_BOTTOM)
(localLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT)).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
// When I try centering the view with this line the edittext view remains at the top. This leads me
// to believe I am missing a basic concept.
//(localLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT)).addRule(RelativeLayout.CENTER_IN_PARENT);
// Create a RelativeLayout View to insert into UnityActivity
RelativeLayout localRelativeLayout = new RelativeLayout(_context);
EditText voiceText = new EditText(_context);
// Add localLayoutParams created above to voiceText
// Create LayoutParams for the RelativeLayout
ViewGroup.LayoutParams vlp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// Add the localRelativeLayout containing voiceText to the unityActivity View
Jun 12 '12 at 04:50 PM