我們的應用程序的主要內容是CardView的RecylerView。註冊時,我們需要的不僅僅是用戶名/密碼來創建一個帳戶,所以我們決定讓註冊流程脫離CardView's,以便在註冊後與用戶體驗相匹配。鍵盤啓動時CardView滾動行爲
要做到這一點,我有一個單獨的活動,從底部將片段和現有片段放在頂部以模擬滾動。這種假滾動發生在用戶輸入數據並點擊前進時。除一種情況外,這種方法非常有效。當我們有一個EditText輸入時,鍵盤出現並覆蓋屏幕底部的'next'按鈕。
在我們的用戶測試中,我們注意到有很高比例的用戶試圖向上滾動卡片以進入下一個按鈕,而不是忽略鍵盤。
我花了很多時間試圖讓CardView滾動顯示按鈕,但我沒有想法並尋找新的東西。
註冊活動佈局只包含一個我加載片段的FrameLayout。每個加載的片段都有一個用於根佈局的CardView。
在清單中,我已經將活動的windowsSoftInputMode設置爲adjustResize,adjustPan成功。
activity_signup.xml
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/signUpContent"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
簡化fragment_enter_code.xml
<android.support.v7.widget.CardView
style="@style/CardViewStyle.SignUp"
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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="25dp"
app:cardElevation="2dp"
app:cardUseCompatPadding="true"
app:contentPadding="8dp">
<EditText
android:id="@+id/codeEditText"
style="@style/HintedEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Code"
android:inputType="text"/>
<Button
style="@style/NextButton"
android:id="@+id/nextButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:text="@string/next"/>
</android.support.v7.widget.CardView>
當我試圖把CardView在滾動型的cardview佈局(與fillViewport真),我得到一個滾動條,但卡不滾動和cardview佈局變得混亂。
有誰知道windowSoftInputMode是否足以指向正確的方向?或者,CardView不會滾動到設計容納它們的Container之外?
感覺這個解決方案是在操作活動的視圖而不是片段。
純粹的迷人 – mjosh