【发布时间】:2020-12-04 12:43:44
【问题描述】:
我希望在片段中的可滚动 ListView 顶部永久浮动一个按钮。我尝试过使用 FrameLayouts、LinearLayout、RelativeLayout 等,但没有任何效果。
这是我正在处理的基本代码:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- New Project Button-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="5dp"
android:id="@+id/fragment_profile_project_relLayoutButton">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fragment_profile_project_newProject_button"
android:layout_alignParentRight="true"
android:paddingHorizontal="15dp"
android:text="@string/project_new_project_button"
android:background="@drawable/white_rounded_button"/>
</RelativeLayout>
<!-- List View-->
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragment_profile_project_listView"
android:layout_marginBottom="50dp"/>
Android Studio 设计视图“理解”我正在尝试执行的操作,但是当我运行应用程序时,只会出现“新建项目”按钮,或者什么也不会出现。
有人知道如何在 ListView 前面获得一个浮动按钮吗?
谢谢,
亚历克斯
【问题讨论】:
-
只在你的列表和浮动按钮中创建一个带有约束视图组的布局,仅此而已
标签: android android-layout android-listview android-view android-button