2013-04-07 76 views
1

我有一個只包含編輯文本視圖的相對佈局。但是,當edittext的內容增加時,我的標題欄會向上移動。我經歷的大多數解決方案解決了鍵盤彈出時移動標題欄的問題。但是,如果內容增加,我沒有發現任何東西。我還使用了android:isScrollContainer =「false」,如How to avoid soft keyboard pushing up my layout?這個帖子所建議的,但仍然是同樣的問題。有沒有辦法阻止它?這裏是我的xml文件 編輯文本內容時,Android標題欄被拉高

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scroll_view" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:isScrollContainer="false" 
    android:background="@drawable/background" > 

    <EditText 
     android:id="@+id/hidden_edit_view" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:imeOptions="flagNoExtractUi" 
     android:inputType="textMultiLine" 
     android:singleLine="false" 
     android:paddingLeft="10sp" 
     android:paddingTop="5sp" 
     android:paddingRight="5sp" 
     android:scrollbars="vertical" 
     android:background="@android:color/transparent" 
     android:textSize="26sp" > 
    </EditText> 
</RelativeLayout> 

回答

1

我設法通過在scrollview中放置edittext並在清單中用adjustSize替換adjustPan來解決此問題。這是最後的工作佈局

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/rl_view" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/background"> 
<EditText 
    android:id="@+id/hidden_edit_view" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@android:color/transparent" 
    android:imeOptions="flagNoExtractUi" 
    android:inputType="textMultiLine" 
    android:paddingLeft="10sp" 
    android:paddingRight="5sp" 
    android:paddingTop="5sp" 
    android:singleLine="false" 
    android:textSize="25sp" > 
</EditText> 
</ScrollView> 
0

嘗試刪除後運行代碼:

android:background="@android:color/transparent" 
+0

還是一樣的,我沒有看到,也沒有工作背景和佈局轉移 – Anurag 2013-04-08 17:47:13

0

讓你的相對佈局的高度和寬度,以wrap_content ..........可能起作用。因爲當文字增加你的完整版面變化。嘗試一下,並請rpy

+0

之間的任何關係,它仍然會認爲 – Anurag 2013-05-07 18:56:02

0

通常這可以通過將android:windowSoftInputMode="adjustPan"屬性添加到您在AndroidManifest文件中的活動來解決。

+0

外面我已經添加了這個屬性我的清單 – Anurag 2013-05-07 18:56:23