向上移动文本视图仅在Android上的虚拟键盘打开 [英] move up text view only when virtual keyboard open on android
问题描述
我的XML code是这里,
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,
执行后,当我进入上编辑文本的价值,虚拟键盘打开,整个mainlayout是向上滚动,我有这样的
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
但我除外,顶部布局不向上滚动,只有底部布局或TextView的向上滚动。我希望这样的,
But i except , the top layout not to scroll up , only the bottom layout or textview scroll up. i expect like this,
如何滚动唯一的编辑视图时打开虚拟键盘。 ?
how to scroll only the edit view when open the virtual keyboard. ?
推荐答案
试试这个;也许是有用的。调整清单
文件
Try this; maybe it is useful. Adjust the manifest
file
<activity
android:windowSoftInputMode="adjustResize"
android:name=".youractivity" android:label="@string/app_name" >
@Ganesh更改清单
像上面的活动
code也正在
@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>
这篇关于向上移动文本视图仅在Android上的虚拟键盘打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!