Reputation: 387
In the app I am designing I have a bottom TabLayout
and ViewPager
on my MainActivity
.
The problem is that each time I click on something that requires input (so the keyboard comes up), that TabLayout sticks to the top of the Keyboard. I would like it to stay where it is - this means it will be hidden by the keyboard.
The problem is expressed in this screenshot. I don't wait it to go to the top of the keyboard.
My manifest file is here (I have tried various combinations of adjustNothing
, adjustPan
, adjustResize
...):
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".PinUpApplication"
android:allowBackup="true"
android:icon="@mipmap/pinup"
android:label="@string/app_name"
android:roundIcon="@mipmap/pinup_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustPan">
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity android:name=".Activities.MainActivity"
android:windowSoftInputMode="adjustPan|adjustResize"
android:screenOrientation="portrait">
</activity>
<activity android:name=".Activities.HorecaActivity"
android:screenOrientation="portrait"/>
<activity android:name=".Activities.HorecaMainActivity"
android:screenOrientation="portrait"/>
<activity android:name=".Activities.EditProfileActivity"
android:screenOrientation="portrait"/>
<activity android:name=".Activities.PersonProfileActivity"
android:screenOrientation="portrait"/>
<activity android:name=".Activities.LoginActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activities.RegisterActivity"
android:screenOrientation="portrait">
</activity>
<activity android:name=".Activities.NoNetworkActivity"
android:screenOrientation="portrait"></activity>
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
</application>
And here below is the code for the activity:
<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/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="@color/white">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="enterAlways">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:windowActionModeOverlay="false"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_search"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:gravity="center_vertical"
android:visibility="gone"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</FrameLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<ro.ineedhelp.pinup.Utils.NonSwipeableViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<FrameLayout
android:id="@+id/main_pager"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:windowSoftInputMode="adjustPan|adjustResize"
android:layout_gravity="bottom"
android:layout_alignParentBottom="false">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
style="@style/MyCustomTabLayout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/white"
app:tabIndicatorColor="@color/colorPrimary"
app:tabIconTint="@color/grey_600"
app:tabTextColor="@color/grey_600"/>
</FrameLayout>
<include
layout="@layout/sheet_activity_map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:layout_behavior="@string/bottom_sheet_behavior" />
Upvotes: 3
Views: 525
Reputation: 312
Try this, for your Main Activity in you manifest file.
android:windowSoftInputMode=" stateAlwaysHidden | adjustPan "
Upvotes: 2