2016-03-10 16 views
2

我的清單文件中試圖獲得的LinearLayout的滾動型何時調整時,閱讀解決此問題多次討論和它與android:windowSoftInputMode="stateHidden|adjustResize"做的(以及adjustPan)顯示鍵盤。Android的滾動型,在操作欄上Softkeyboard

我有具有包含10個的LinearLayout部分(的TextView/EditText上視圖)滾動型的內部的的LinearLayout的佈局。我想盡我已閱讀並不管如何,當鍵盤被打開,點擊頂部的EditText的結果,認爲調整組合(平移),使得前場是行動吧檯後面。我可以滾動到頁面的底部,但我無法到達頂部EditText - 我只能滾動到第二個。我可以嘗試拉下來,我可以開始看到頂部的EditText,但不能得到它顯示,除非我取消鍵盤(這顯然我不能編輯的文本,然後)。

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    tools:context="com.example.myproject.FirstActivity" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/scrollView" 
    tools:showIn="@layout/activity_work" 
    android:layout_gravity="center_horizontal"> 

    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:text="x1" 
      android:layout_weight="50"/> 

     <EditText 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:inputType="numberDecimal" 
      android:ems="10" 
      android:id="@+id/work_one" 
      android:hint="0" 
      android:gravity="right" 
      android:selectAllOnFocus="true" 
      android:textAlignment="gravity" 
      android:layout_weight="50" /> 
    </LinearLayout> 
    . 
    . (9 more of these) 
    . 
    </LinearLayout> 
</ScrollView> 

UPDATE:

所以我嘗試:機器人:windowSoftInputMode = 「adjustResize」 和/或機器人:windowSoftInputMode = 「adjustPan」 和軟鍵盤移位操作欄下的頂部字段。

想法?

+0

嘿,我面臨同樣的問題。你有沒有解決這個問題? –

回答

1

嘗試無論是安卓windowSoftInputMode = 「adjustResize」 或Android:windowSoftInputMode = 「adjustPan」

doc

「adjustResize」

活動的主窗口總是被調整,使屏幕上軟鍵盤的空間。不調整

「adjustPan」

活動的主窗口,以騰出空間給軟鍵盤。相反,窗口的內容會自動平移,以便當前焦點永遠不會被鍵盤遮擋,用戶始終可以看到他們正在鍵入的內容。這通常不如調整大小,因爲用戶可能需要關閉軟鍵盤才能與窗口的隱蔽部分進行交互。

我複製了this Stack Overflow answer的答案

+0

感謝奇才,我試過adjustPan以及(實際上是試圖|兩者的它仍然在操作欄下,去奇......。 – justdan0227