Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

push only scrollview while keyboard open android

Tags:

android

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

like image 450
Siddhpura Amit Avatar asked Feb 13 '15 08:02

Siddhpura Amit


2 Answers

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"

like image 51
Evripidis Drakos Avatar answered Nov 15 '22 20:11

Evripidis Drakos


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"
like image 27
Moubeen Farooq Khan Avatar answered Nov 15 '22 19:11

Moubeen Farooq Khan