我使用一個名爲DragListView
here的外部庫。這DragListView
延伸FrameLayout
它裏面包含RecyclerView
。結構如下:Android - AdjustResize將無法使用擴展FrameLayout的外部庫
DragListView extends FrameLayout {
RecyclerView mRecyclerView;
}
填充到RecyclerView中的項目包含EditText
。靠近屏幕頂部的EditText
(如果出現軟鍵盤,則不包括該屏幕)可以正常工作。但是被軟鍵盤覆蓋的那個將會獲得焦點,然後在被稱爲myEditText.requestFocus();
時失去焦點,然後鍵盤覆蓋那個EditText
。
這是我的活動的佈局。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.ui.activities.ChecklistsActivity">
<include layout="@layout/custom_action_bar"
android:id="@+id/action_bar"/>
<com.woxthebox.draglistview.DragListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:id="@+id/recycler_view_checklists"
/>
</LinearLayout>
android:layout_gravity="top"
作品我曾經用我的舊的結構,其中DragListView是RecyclerView
(我設置了RecyclerView
頂部重力)內嵌套的孩子,但它不是在這種情況下工作了。
我不能使用AdjustPan
,因爲它會將我的操作欄推開(但它可行,可悲)。我的應用程序不是全屏(仍然能夠看到狀態欄,我認爲它不是全屏,請糾正我,如果我錯了)。我嘗試了一些東西,但沒有任何工作。
我在myEditText.requestFocus();
之前撥打myEditText.setFocusable(true);
和myEditText.setFocusableInTouchMode(true);
。
我把android:descendantFocusability="afterDescendants"
代替爲DragListView
或根LinearLayout
。
我打過電話鍵盤不同的方式來彈出像
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
或與收到的活動爲getCurrentFocus();
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
還有一件事以防萬一KeyboardUtils。我不知道是否有與我的「自定義」鍵盤有關的任何東西,因爲我想要一個帶有「完成」操作鍵的多行EditText
。該EditText
項目的XML是在這裏:
<EditText
android:id="@+id/edit_text_sub_checklist_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/height_checklist_setting"
android:layout_marginRight="@dimen/height_checklist_setting"
android:inputType="text"
android:imeOptions="actionDone"
android:maxLength="256"
android:textSize="@dimen/text_size_default"
android:visibility="invisible" />
的android:visibility="invisible"
是因爲有一個按鈕,按下使其可見。
我生氣了幾天。我錯過了什麼嗎?隨時索取更多信息。
謝謝大家寶貴的時間。