只有当虚拟键盘在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> 

当我执行,我有这样的,

在这里输入图像描述

执行后,当我input编辑文本的值,虚拟键盘打开,整个mainlayout向上滚动,我喜欢这个

在这里输入图像描述

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

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

尝试这个; 也许它是有用的。 调整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>