1

Objective

When a keyboard is shown, I would like to have the bottommost elements on my screen visible always.

Current Implementation

The current implementation that I have tried (outlined below) has worked in allowing the content to scroll; however, I have failed at getting the scroll view to default to being at the bottom on the scroll.

AndroidManifest.xml

 <activity
        android:name=".OnboardingActivity"
        android:configChanges="orientation"
        android:windowSoftInputMode="stateVisible|adjustResize"
        android:label="@string/title_activity_onboarding"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme" />

Fragment

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

    <include
        layout="@layout/toolbar_default" />

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:orientation="vertical">


           <!-- Here are a bunch of elements, the bottommost of which I would like visible when the keyboard is shown -->

        </LinearLayout>

    </ScrollView>

</LinearLayout>
ankuranurag2
  • 2,300
  • 15
  • 30
Anthony Dito
  • 3,610
  • 3
  • 29
  • 56

1 Answers1

1

Off the top of my head, this is how I would implement it.

Check for soft keyboard visibility. From this, you can get the visibility status. If keyboard is visible, do so:

scrollView.fullScroll(View.FOCUS_DOWN);

Cheers!

user1506104
  • 6,554
  • 4
  • 71
  • 89