【发布时间】:2018-12-01 10:46:37
【问题描述】:
我想在 xml 文件中包含另一个包含 fab 按钮的其他 xml 文件。问题是当我 <include layout="@layout/fab
它在屏幕的左上角而不是右下角显示我的 fab 按钮。
这是我的 xml 文件(ConstraintLayout)
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PlanPage.PlanPageView">
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/activity_fab_button"
android:layout_gravity="end|bottom"/>
</android.support.constraint.ConstraintLayout>
这是fab按钮xml
<android.support.design.widget.FloatingActionButton
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:src="@drawable/ic_plusphoto_fab"
android:backgroundTint="@color/colorPrimary"
/>
【问题讨论】:
-
你可以尝试在
include中添加marginBottom吗?? -
我添加了
android:layout_marginBottom="200dp"只是为了检查,它不起作用 -
请尝试设置
alignParant`bottom
标签: android xml include floating-action-button