Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(tablayout) Tabs come over the keyboard when editText is focused

I have setUp tabLayout with ViewPager which has 5 Fragments. tabLayout with android:layout_gravity set to bottom . Third fragment has editText which when focused , my tabs come over the keyboard.

Tablayout without EditText

TabLayout with EditText

Main layout :

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/coordinatorLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

         <include
              android:id="@+id/t"
             layout="@layout/toolbar"/>


        </android.support.design.widget.AppBarLayout>

  <android.support.v4.view.ViewPager
    android:id="@+id/viewPager"
    android:layout_width="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"/>

  <android.support.design.widget.TabLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tab="http://schemas.android.com/tools"
    android:layout_gravity="bottom"
    app:tabGravity="fill"
    android:background="@color/colorPrimary"
    android:layout_alignParentBottom="true"
    android:id="@+id/tabs"

    app:layout_collapseMode="parallax"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"

    xmlns:android="http://schemas.android.com/apk/res/android">


    </android.support.design.widget.TabLayout></android.support.design.widget.CoordinatorLayout> 

Third Fragment layout :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="40dp"
        android:hint="Enter something"
        />
</LinearLayout> 
like image 929
Mohan Avatar asked Jul 23 '16 19:07

Mohan


1 Answers

Open AndroidManifest.xml and add to your activity tag android:windowSoftInputMode="adjustPan"

If this doesn't work add android:windowSoftInputMode="adjustNothing"

This will prevent the soft keyboard from adjusting the layout.

Hope this helps.

like image 112
odinlp2 Avatar answered Oct 31 '22 15:10

odinlp2