Question

I have a program which uses an Android device as an interface to another PIC-based system. The Android has two modes of operation - in one, it gives an HMI-style display showing the status of the connected system: in the other, it acts as a dumb terminal allowing me to program and alter the monitored system. empty terminal screen

I am using a fragment to handle the terminal activities. This has a TextView showing the past history of entered text and responses, with another TextView allowing me to enter a command line. On first starting the program and accessing the terminal display, touching the text entry TextView brings up the keyboard, with the other two TextViews moving up the display to make room for it. This is what I want. terminal screen with keyboard - as required

I can access the HMI display by saving the FragmentInstanceState and then using fragTrans.hide(). If I then return to the terminal fragment and start re-entering text, the keyboard now overlays the two TextViews, which hides the text entry box. enter image description here

enter image description here The only difference in the two modes is that on re-entering the fragment I use fragTrans.show() to display the terminal mode: when first starting, I use fragTrans.add().

Another change between the first use of the terminal and subsequent accesses is that the button I use to access the terminal is initially overlaid, but appears above the keypad later.

Is this issue due to differences between the fragment.show() and fragment.add() functions, or is there another aspect I am missing?

Was it helpful?

Solution

I believe it has to do with the activity you're using to hold these fragments. Within your manifest file, add the following code to your activity to have the screen adjust when the soft-input is shown.

If you are using two activities, make sure both of them have the following:

android:windowSoftInputMode="adjustPan"

<activity
    android:name="com.yourapp.MainActivity"
    android:label="@string/app_name"
    android:windowSoftInputMode="adjustPan" >
</activity>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top