ボタンをクリックすると、EditText
a の上にan を膨らませようとしていRecyclerView
ます。ただし、EditText がレイアウトの上部に追加されて RecyclerView が押し下げられるのではなく、RecyclerView の上に配置され、次のようにカバーされます。
「New Text」が RecyclerView の最初の項目を覆っていることがわかります。RecyclerView の上に膨らませて、RecyclerView を押し下げて、新しく追加された EditText に対応するにはどうすればよいですか?
EditText を追加する FrameLayout の XML は次のとおりです。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragment_my_frame_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
<com.melnykov.fab.FloatingActionButton
android:id="@+id/button_floating_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="@drawable/ic_action_new"
fab:fab_colorNormal="@color/primary_dark"
fab:fab_colorPressed="@color/primary" />
RecyclerView の上に EditText を追加する私の FloatingActionButton の onClick メソッドは次のとおりです。
public void onClick(View v) {
ViewGroup parent = (ViewGroup) rootView.findViewById(R.id.fragment_my_frame_layout);
View view = LayoutInflater.from(getActivity()).inflate(R.layout.add_keyword_edittext, parent, true);
}
追加する EditText の XML は次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/edit_text_above_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:background="#00000000"
android:textCursorDrawable="@null"
android:imeOptions="actionDone"
android:singleLine="true"
android:text="New Text" />