我尝试了几乎所有关于在Xamarin布局中放置浮动操作按钮的代码和建议,但我总是得到一个膨胀错误。这是XML文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The Main Content View -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="10 mins"
android:textSize="100dp"
android:gravity="center"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/timerView" />
<TextView
android:text="left of Period 4"
android:textSize="20dp"
android:gravity="center"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/timerView"
android:id="@+id/timerViewBottom" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/myFAB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_plus_sign"
app:elevation="4dp"/>
</RelativeLayout>
<!-- The Left Navigation Drawer -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#818181"
android:dividerHeight="1dp"
android:background="#D3D3D3" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
我使用的是AppCompat主题。怎么啦?我的android api是23
发布于 2016-07-08 19:09:20
你在列表视图中附加了你的floatingActionButton吗?
在您的活动或片段中,无论是什么,您必须在列表视图中附加浮动按钮,如下所示:
var myListView = FindViewById<ListView>(Resource.Id.left_drawer);
var myFloatingButton = FindViewById<FloatingActionButton>(Resource.Id.myFAB);
myFloatingButton.AttachToListView(myListView);
https://stackoverflow.com/questions/38173808
复制相似问题