9

Hi I have Activity which contain 3 view

-RelativeLayout
---TextView                 1)
---ScrollView               2)
-----FrameLayout
---------ListView
---------EditText -----------> When I click over here (2) view only pushup
---TextView                 3)

I want only 2) which is scrollview should pushup when keyboard open, but right now it push TextView 3) also

I have tried with in menifest

android:windowSoftInputMode="adjustNothing"
or
android:windowSoftInputMode="adjustResize" 
or
android:windowSoftInputMode="adjustPan" 

but nothing happens, 3) textview also pushes with 2) Scrollview

Panchal Amit
  • 12,802
  • 10
  • 73
  • 137

3 Answers3

9

Opening the soft keyboard reduces the available screen space, it doesnt change the fact that the TextView 3) is at the bottom of the screen.

So, if I understand correctly you want to not display the TextView 3) when you open the keyboard?

If that's so, you could try using this method here to capture the showing/hiding of the soft keyboard and show/hide the Textview.

EDIT Also try using android:isScrollContainer="false" on the scrollview with android:windowSoftInputMode="adjustNothing" or android:windowSoftInputMode="adjustPan"

Evripidis Drakos
  • 822
  • 1
  • 7
  • 15
  • It should be, though it could depend on target api (haven't tested it myself on newer apis) but it's not so difficult to test it yourself :) – Evripidis Drakos May 26 '16 at 10:21
3

what you can do is to detect the keyboard if it is showing hide the text view and id not then show it

here is a piece of code

_Your_Text_View.getViewTreeObserver().addOnGlobalLayoutListener(
            new OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    Rect r = new Rect();
                    // r will be populated with the coordinates of your view
                    // that area still visible.
                    activityRootView.getWindowVisibleDisplayFrame(r);
                    heightDiff = activityRootView.getRootView()
                                .getHeight() - (r.bottom - r.top);


                if (heightDiff > 100) { // if more than100 pixels, its
                            // probably a keyboard...

                    //here hide your TextView
                }else{

                         //here Show your TextView
                }
            });

also write that piece of code in you menifest

android:windowSoftInputMode="stateHidden|adjustPan"
Moubeen Farooq Khan
  • 2,815
  • 1
  • 8
  • 26
0

Guys i fell into the same issue and got refuge through a very handy and easiest solution that involves putting an attribute in your Scrollview tag residing in your xml file. That is

android:isScrollContainer="false"

This prenvents the bottom layout to sit on the keyboard. Hope it resolves the issue.

Ali Nawaz
  • 993
  • 11
  • 19