【发布时间】:2018-07-21 09:51:35
【问题描述】:
我有一个选项卡活动,其中有 3 个选项卡。一切正常,但我想在片段底部添加一个按钮,该按钮应固定在 FAB 之类的位置。按钮布局在底部但只有当我向下滚动片段时。我想要的是按钮布局应该固定在一个位置,即使它上面的recyclerview被滚动。如何实现它,有人可以帮忙吗? 我的xml代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_messages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padd_5"
android:layout_weight="1" />
<LinearLayout
android:id="@+id/replyLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padd_2"
android:layout_weight="0"
android:background="@drawable/custom_border"
android:padding="@dimen/padd_5">
<EditText
android:id="@+id/edt_reply"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/write_a_comment"
android:textColor="@color/grey"
android:textSize="15sp" />
<Button
android:id="@+id/btn_reply"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="center"
android:background="@color/colorAccent"
android:text="@string/reply"
android:textAllCaps="false"
android:textColor="@color/white" />
</LinearLayout>
</LinearLayout>
回复布局正在显示,但是当我向上滚动时
我想要的是,回复布局应该固定在一个位置,recyclerview内容应该在它后面。回复布局应该固定在突出显示的位置
【问题讨论】:
-
您想在 recyclerview 下方或 recyclerview 上方添加按钮?
-
@HemantParmar 在回收站视图上
-
可以,而不是使用 RelativeLayout 而不是线性。
-
如果我使用相对布局,那么编辑文本会变得透明,这是我不想要的
标签: android android-layout android-linearlayout