【发布时间】:2017-02-11 07:51:44
【问题描述】:
在我的应用程序中,ListFragment 中有一个 FloatingActionButton。
这是ListFragment的布局:
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@android:layout/list_content"/>
<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@id/android:empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/no_contacts"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="@drawable/ic_add"
app:layout_anchor="@id/android:list"
app:layout_anchorGravity="bottom|end"
android:layout_alignParentEnd="true"/>
</android.support.design.widget.CoordinatorLayout>
在 Android Studio 中,FAB 位于 bottom-right 位置,但当我运行应用程序时,它位于 top-left。
【问题讨论】:
标签: android user-interface material-design floating-action-button