Подтвердить что ты не робот

Перемещать текстовое представление только при открытии виртуальной клавиатуры на Android

Мой xml-код здесь,

<?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>

когда я выполняю, я получил это,

enter image description here

после выполнения, когда я ввожу значение в текст редактирования, виртуальная клавиатура открыта, и вся основная прокрутка прокручивается вверх, я получил вот это

enter image description here

Но кроме того, верхний макет не прокручивается вверх, прокручивается только нижний макет или текст. я ожидаю такого, enter image description here

как прокручивать только вид редактирования при открытии виртуальной клавиатуры.

4b9b3361

Ответ 1

Попробуйте это; возможно, это полезно. Откорректируйте файл manifest

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

@Ganesh, вы меняете manifest, как и выше, ваш код Activity также работает

 <?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>