Reputation: 2564
I am using TabLayout, which position in the bottom of the screen. The problem is when the keyboard open the TabLayout also comes above of the keyboard.
I want to hide behind the keyboard
In Manifest I set android:windowSoftInputMode="adjustResize"
, if I change to adjustSpan, even the tile bar goes up when keyboard open.
Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MissingPrefix"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@color/white"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="@+id/tb_toolbar_main_activity"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"
app:layout_scrollFlags="enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/tb_heading"
fontPath="@string/font_bebas_neue_bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:text="@string/app_name_caps"
android:textAlignment="center"
android:textColor="@color/heading_color"
android:textSize="@dimen/toolbar_title_text" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/vp_activity_main"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="@color/white"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabBackground="@drawable/tab_back_selected"
app:tabIndicatorHeight="0dp"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabSelectedTextColor="@android:color/white"
app:tabTextAppearance="@style/MyTabLayoutTextAppearance"
app:tabTextColor="@color/home_sub_text"
/>
Upvotes: 0
Views: 1044
Reputation: 969
In you manifest add android:windowSoftInputMode="adjustPan|adjustNothing"
Try to take the relative layout as parent layout and give your tablyout attribute as alignparentbottom= true.
Put the other layout above this tablayout.
Hope this will help.
Upvotes: 0
Reputation: 353
I also face same issue and i fixed it by adding below code. Please try this
In build.gradle file
implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.2.1'
In Manifest.xml
android:windowSoftInputMode="adjustResize"
In Activity class
TabLayout tabs = findViewById(R.id.tabs);
KeyboardVisibilityEvent.setEventListener(
MainActivity.this,
new KeyboardVisibilityEventListener() {
@Override
public void onVisibilityChanged(boolean isOpen) {
if(isOpen){
tabs.setVisibility(View.GONE);
} else {
tabs.setVisibility(View.VISIBLE);
}
}
});
Upvotes: 2