I have an activity which has a layout content 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 viewpager, I have a fragment which 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 doesn't fit the screen, the scrollview allows the user to see the content which is below the screen. (Works as expected)
The problem is when the edittext gets focus, the keyboard overlaps the edittext area, rather than the scrollview causing the content to scroll.
I expect the fragment to handle keyboard shown and scrollview to fit the keyboard on the screen.
Or am I wrong and is activity responsible for the keyboard? Since the root view in activity layout is linearlayout, is it restricting the expansion?
I tried wrapping the whole content of the activity layout with a scrollview, but this time viewpager doesnt appear on the screen if I don't give it a fixed size. Even when I do, I end up having a scrollview inside the fragment which is under the scrollview of the main layout and still keyboard is hovering over the edittext.
I'm a bit lost here, my objective is to be able to scroll the fragment content when the edittext gets focused, but rather the keyboard overlaps the edittext currently.
android:windowSoftInputMode="adjustResize|adjustPan"
? – muratgu