Alan Ford
Alan Ford

Reputation: 375

RelativeLayout is not Scrollable in ScrollView

Any idea why the following layout is not scrollable? I have a RelativeLayout in a ScrollView. The Views fit on the screen. however they are covered whenever the keyboard pops up. I want to make the screen scrollable when the keyboard pops up, because it covers the Login and password EditBoxes so it is har to see what someone is typing

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

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <com.alarm.alarmmobile.android.view.RobotoLightTextView
            android:id="@+id/passcode_login_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginTop="20dp"
            android:text="@string/passcode_login_body"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <EditText
            android:id="@+id/passcode_login_username"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/passcode_login_text"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginTop="20dp"
            android:hint="@string/login_textview_username"
            android:singleLine="true" />

        <EditText
            android:id="@+id/passcode_login_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/passcode_login_username"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:hint="@string/login_textview_password"
            android:inputType="textPassword"
            android:singleLine="true" />

        <com.alarm.alarmmobile.android.view.RobotoLightButton
            android:id="@+id/passcode_login_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_below="@id/passcode_login_password"
            android:layout_marginRight="16dp"
            android:paddingLeft="20dp"
            android:paddingRight="20dp"
            android:text="@string/login_button_login" />

    </RelativeLayout>

</ScrollView>

Upvotes: 0

Views: 68

Answers (3)

Huy Tran
Huy Tran

Reputation: 198

Include this in your Manifest:

<activity android:name="..." // your activity here
    ....
    android:windowSoftInputMode="adjustResize|adjustPan">
/>

NOTE: Not sure if adding adjustPan will cause the problem to come up again or not.

Upvotes: 1

luiscosta
luiscosta

Reputation: 855

On the activity or fragment class of this layout you have to call this:

getWindow().setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

Upvotes: 1

Mark N
Mark N

Reputation: 336

If everything can fit on the screen, the ScrollView will not be able to scroll anywhere. If there is a component that is not fully visible then the scroll should be available to see the rest of the component. Without being able to see what the problem is it's hard to find the exact solution.

Upvotes: 0

Related Questions