[英]move up text view only when virtual keyboard open on 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>
當我執行時,我得到這樣的,
執行后,當我在編輯文本中輸入值時,虛擬鍵盤打開,整個主布局向上滾動,我得到這樣的
但我除了,頂部布局不向上滾動,只有底部布局或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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.