I am using bottom TabLayout
with ViewPager
above the tabs, XML listed below:
<RelativeLayout
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/toolbar_wrapper"
layout="@layout/toolbar_main" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs_bottom_main"
style="@style/AppTabLayout"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
app:tabGravity="fill" />
<View
android:id="@+id/view_black_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_above="@id/tabs_bottom_main"
android:background="@android:color/black" />
<NonSwipableViewPager
android:id="@+id/view_pager_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/view_black_line"
android:layout_below="@id/toolbar_wrapper"
android:background="@android:color/white" />
</RelativeLayout>
When the keyboard shows up, the whole View
pushed up, I would like to hide the bottom TabLayout
only (but keep the ViewPager
above) once the keyboard shows up. How to achieve it?
P.S.
I have tried listening the keyboard show up event and set TabLayout
visibility with mBottomTabLayout.setVisibility(isOpen ? View.GONE : View.VISIBLE);
But this will hide the whole ViewPager
together with the TabLayout
.
It works after I change RelativeLayout
to LinearLayout
according to @Rahul Sharma's advice.
Then I used the KeyboardVisibilityEvent library:
KeyboardVisibilityEvent.setEventListener(this,
new KeyboardVisibilityEventListener() {
@Override
public void onVisibilityChanged(boolean isOpen) {
mBottomTabLayout.setVisibility(isOpen ? View.GONE : View.VISIBLE);
}
});