ip696
ip696

Reputation: 7104

ScrollView not scrolll when open soft keyboard

I want open soft Keyboard and scroll edittext above keyboard. But it must be in scrollView. Now i have wrong result: video

I do not want scroll top views. I want scroll only edittext.

And i use this theme:

<style name="Theme.TransparencyDemo" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
    </style>

EDIT:

new video sample

Layout:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"
              android:weightSum="1"
                android:background="#142e06">


    <TextView
        android:layout_width="100dp"
        android:layout_height="30dp"
        android:text="New Text"
        android:id="@+id/textView"
        android:background="#ff4018"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"/>

    <EditText
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:id="@+id/editText"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="150dp"/>

</RelativeLayout>

Upvotes: 2

Views: 690

Answers (2)

Max
Max

Reputation: 5743

Add this in your layout android:fitsSystemWindows="true"like this

<RelativeLayout 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="wrap_content">
    <include layout="@layout/toolbar" />
     <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"      
        ndroid:fitsSystemWindows="true"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin">


        <!-- Your Content here -->


    </LinearLayout>
</RelativeLayout>

That will work

Upvotes: 0

Anwar Kamal
Anwar Kamal

Reputation: 405

Use LinearLayout instead of Relative and add this line to your activity tag in manifest

 android:windowSoftInputMode="adjustPan"

Upvotes: 1

Related Questions