仅当在android上打开虚拟键盘时才向上移动文本视图

RVG*_*RVG 12 android android-layout

我的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>
Run Code Online (Sandbox Code Playgroud)

当我执行时,我得到这样的,

在此输入图像描述

执行后,当我在编辑文本中输入值时,虚拟键盘打开,整个主布局向上滚动,我得到这样的

在此输入图像描述

但我除了,顶部布局不向上滚动,只有底部布局或textview向上滚动.我希望这样, 在此输入图像描述

打开虚拟键盘时如何仅滚动编辑视图.?

Nag*_*ddy 23

试试这个; 也许它很有用.调整manifest文件

<activity
      android:windowSoftInputMode="adjustResize"              
      android:name=".youractivity" android:label="@string/app_name" >
Run Code Online (Sandbox Code Playgroud)

@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>
Run Code Online (Sandbox Code Playgroud)