I have an activity that has the contents of a layout as follows:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" android:minHeight="?attr/actionBarSize" style="@style/ToolBarStyle.Event" /> <com.mypackage.corecode.ui.view.SlidingTabLayout android:id="@+id/sliding_tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/primary_color" /> <android.support.v4.view.ViewPager android:id="@+id/vendor_main_tabview_pager" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> </LinearLayout>
And inside the viewpager, I have a fragment that has the following layout:
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:weightSum="3" android:orientation="horizontal"> <EditText android:theme="@style/ScrollableContentThemeNoActionBar" android:id="@+id/edit_text_vendor_sms_phone_number" android:layout_width="0dp" android:layout_weight="2" android:layout_height="wrap_content" android:inputType="number" /> <Button android:id="@+id/button_send_sms" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" /> </LinearLayout> </LinearLayout> </ScrollView>
When the content inside the fragment does not fit the screen, scrollview allows the user to see the content below the screen. (Works as expected)
The problem is that edittext gets focus, the keyboard overlaps the edittext area, not the scroll, causing the content to scroll.
I expect the fragment to process the displayed keyboard and scroll according to the keyboard on the screen.
Or am I mistaken and responsible for the keyboard? Since the root view in the activity layout is linearlayout, does it limit the extension?
I tried to wrap the entire content of the activity layout with scrollview, but this time the viewpager will not appear on the screen unless I give it a fixed size. Even when I do this, I get a scrollview inside the fragment that is under the scroll of the main layout, and still the keyboard is hovering over the edittext.
I got a little lost here, my goal is to scroll through the contents of the fragment when the edittext is focused, but the keyboard is overlapping the edittext at the moment.