Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

move up text view only when virtual keyboard open on android

My xml code is here,

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/mainlayout" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true" 
    android:id="@+id/toplayout">
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:src="@drawable/bg" />
</LinearLayout>


<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true" 
    android:id="@+id/bottomlayout">
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="Enter value" />
</LinearLayout>

when i execute , i got like this,

enter image description here

after execute , when i enter the value on edit text ,the virtual keyboard is open and the entire mainlayout is scroll up, i got like this

enter image description here

But i except , the top layout not to scroll up , only the bottom layout or textview scroll up. i expect like this, enter image description here

how to scroll only the edit view when open the virtual keyboard. ?

like image 318
RVG Avatar asked Jun 20 '12 12:06

RVG


People also ask

How do you move the layout up when the soft keyboard is shown IOS?

Scrolling up scrollview when keyboard is shown We can add bottom padding into the scrollview using its contentInset property, so the content inside will be moved up when a keyboard is shown. You can think of contentInset as an additional padding extending from the content area edges.

How do I turn off text view on Android?

It's possible to preserve both the style of the view and the scrolling behaviour. To disable an EditText while keeping this properties, just use UI. setReadOnly(myEditText, true) from this library. If you want to replicate this behaviour without the library, check out the source code for this small method.

What is soft input mode in Android?

The Android system shows an on-screen keyboard—known as a soft input method—when a text field in your UI receives focus.


1 Answers

Try this; maybe it is useful. Adjust the manifest file

<activity
      android:windowSoftInputMode="adjustResize"              
      android:name=".youractivity" android:label="@string/app_name" >

@Ganesh you change manifest like above your Activity code also working

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

  <RelativeLayout
     android:layout_width="fill_parent"
     android:layout_height="wrap_content" 
     android:id="@+id/toplayout">
     <ImageView
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:src="@drawable/ic_launcher" />   
     <EditText
         android:layout_width="fill_parent"
         android:layout_alignParentBottom="true"   
         android:layout_height="wrap_content"
         android:hint="Enter value" />

     </RelativeLayout>
</LinearLayout>
like image 78
NagarjunaReddy Avatar answered Sep 29 '22 12:09

NagarjunaReddy