简体   繁体   中英

View in scrollview gets hidden when requestFocus() is called

I have a ScrollView where there are a number of EditText fields.

When i call requestFocus() on any of those fields, the EditText fields comes into view as the scroll view scrolls by itself, even when the soft keyboard is up.

The problem lies in the fact that i have had to add a separate view above the soft keyboard to accommodate a clear button, and it is that custom view that is hiding the edit text field in focus.

Now, i have to manually scroll the scroll view to see the edit text field in focus.

Please help me to show the edit text field in focus above the custom view which is placed on top of the soft keyboard.

Is there any way to do so ?

EDIT:: This is how i solved this problem.

scrollView.post(new Runnable() { 
                    public void run() { 
                        scrollView.scrollTo(0, scrollView.getBottom()-200);
                    } 
            });                                         

and gradually went on decreasing the amount i am subtracting from the scrollView.getBottom() call. This worked fine for me.

在您的manifest.xml文件中,为您的活动添加以下行:

android:windowSoftInputMode="adjustPan"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM