【发布时间】:2015-08-17 14:28:50
【问题描述】:
我想在我的列表视图上方显示 FloatingActionButton。我在我的 activity_main.xml 中使用此代码:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/drawer_layout"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/main_content"
android:orientation="vertical"
>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:id="@+id/app_bar"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="16dp"
android:src="@drawable/ic_refresh"
/>
<!-- List view goes here-->
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="@color/list_divider"
android:dividerHeight="1dp"
android:focusable="false"
android:listSelector="@drawable/list_row_selector"
android:id="@+id/listView"></ListView>
</LinearLayout>
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_drawer"
android:layout_gravity="start"
app:menu="@menu/menu_drawer"
app:itemIconTint="@color/colorAccent"
app:itemTextColor="@color/colorTextSecondary"
>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
我希望它出现在列表视图的顶部,直到列表视图完全加载。 另外,如何获得旋转刷新图标?请帮我解决这个问题。
【问题讨论】: