android浮于上方布局,android-在FrameLayout中使RecyclerView上方的视图...

在单击按钮时,我试图在RecyclerView上方填充EditText.但是,不是将EditText添加到布局的顶部,从而按下了RecyclerView,而是将其简单地放置在RecyclerView的顶部,如下所示:

您会看到“ New Text”正在覆盖RecyclerView的第一项.我如何才能使其在RecyclerView上方膨胀,并使RecyclerView向下推,以容纳新添加的EditText?

这是我将EditText添加到的FrameLayout的XML:

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:id="@+id/my_recycler_view"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:scrollbars="vertical" />

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" />

这是我的FloatingActionButton的onClick方法,我希望在其中将EditText添加到RecyclerView上方:

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:

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" />

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值