2012-06-20 37 views
12

mã XML của tôi là ở đây,di chuyển lên xem văn bản chỉ khi bàn phím ảo mở trên android

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

khi tôi thực hiện, tôi đã nhận như thế này,

enter image description here

sau thực thi, khi tôi nhập giá trị vào văn bản chỉnh sửa, bàn phím ảo đang mở và toàn bộ mainlayout đang cuộn lên, tôi nhận được như thế này

enter image description here

Nhưng tôi ngoại trừ bố cục trên cùng không cuộn lên, chỉ bố cục phía dưới hoặc chế độ xem văn bản cuộn lên. tôi mong đợi như thế này, enter image description here

cách chỉ cuộn chế độ xem chỉnh sửa khi mở bàn phím ảo. ?

+1

Hãy thử bằng cách thêm android: windowSoftInputMode = "adjustPan | adjustResize" cho các hoạt động trong file manifest của bạn. – vrs

Trả lời

21

Hãy thử điều này; có lẽ nó rất hữu ích. Điều chỉnh manifest tập tin

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

@Ganesh bạn thay đổi manifest như trên mã Activity của bạn cũng làm việc

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

Cảm ơn bạn. Làm việc tốt đẹp của nó. – RVG

+0

Tại sao chúng tôi muốn thay đổi kích thước chế độ xem khi bàn phím mềm được khởi chạy? –

Các vấn đề liên quan