Xamarin Andriod的背景中显示了FloatingActionButton菜单

时间:2019-04-02 06:16:19

标签: xamarin.android material-design material-ui

使用Material设计,Xamarin Android中的FloatingActionButton显示在背景中。我尝试了Bringfront(),但是没有用。如何使FloatingActionButton菜单显示在前面而不是背景?

enter image description here

Design.axml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    i
    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:local="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/primary"
        local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
    <android.support.design.widget.TextInputLayout
        android:id="@+id/input_layout_password"
        android:layout_width="match_parent"
        android:paddingTop="25dp"
        android:layout_height="wrap_content">
        <EditText
            android:id="@+id/DatePicker"
            android:focusableInTouchMode="false"
            android:layout_width="match_parent"
            android:inputType="text"
            android:drawableRight="@drawable/calendar_month"
            android:layout_marginLeft="20dp"
            android:clickable="true"
            android:layout_marginRight="20dp"
            android:layout_height="50dp"
            android:background="#FFF8F9FA"
            android:hint="Select Date"
            android:layout_weight="15"
            android:textColor="#FF808080" />
    </android.support.design.widget.TextInputLayout>
    <android.support.design.widget.TextInputLayout
        android:id="@+id/Indberettet"
        android:layout_width="match_parent"
        android:paddingTop="5dp"
        android:layout_height="wrap_content">
        <EditText
            android:id="@+id/IndberettetePicker"
            android:focusableInTouchMode="false"
            android:layout_width="match_parent"
            android:inputType="text"
            android:layout_marginLeft="20dp"
            android:clickable="true"
            android:layout_marginRight="20dp"
            android:layout_height="50dp"
            android:background="#FFF8F9FA"
            android:hint="Indberettet på Vegne af en Anden"
            android:layout_weight="15"
            android:textColor="#FF808080" />
    </android.support.design.widget.TextInputLayout>
    <android.support.design.widget.TextInputLayout
        android:id="@+id/input_layout_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <EditText
            android:id="@+id/IndberettetePicker"
            android:focusableInTouchMode="true"
            android:layout_width="match_parent"
            android:inputType="text"
            android:layout_marginLeft="20dp"
            android:clickable="true"
            android:layout_marginRight="20dp"
            android:layout_height="50dp"
            android:background="#FFF8F9FA"
            android:hint="Hændelses type"
            android:layout_weight="15"
            android:textColor="#FF808080" />
    </android.support.design.widget.TextInputLayout>
    <android.support.design.widget.TextInputLayout
        android:id="@+id/input_layout_password"
        android:layout_width="match_parent"
        android:paddingLeft="20dp"
        android:layout_height="wrap_content">
        <EditText       
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:ems="10"
            android:hint="Hændelsesbeskrivelse"
            android:minLines="3"
            android:gravity="left|top"
            android:inputType="textMultiLine" >
            <requestFocus />
        </EditText>
    </android.support.design.widget.TextInputLayout>
    <android.support.design.widget.TextInputLayout
        android:id="@+id/input_layout_password"
        android:layout_width="match_parent"
        android:paddingLeft="20dp"
        android:layout_height="wrap_content">
        <EditText       
            android:id="@+id/editText3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:ems="10"
            android:hint="Hændelsessted / Adresse"
            android:minLines="3"
            android:gravity="left|top"
            android:inputType="textMultiLine" >
            <requestFocus />
        </EditText>
    </android.support.design.widget.TextInputLayout>
    <android.support.design.widget.TextInputLayout
        android:id="@+id/input_layout_password"
        android:layout_width="match_parent"
        android:paddingLeft="20dp"
        android:layout_height="wrap_content">
        <EditText       
            android:id="@+id/editText3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:ems="10"
            android:hint="Forebyggende foranstaltninger"
            android:minLines="3"
            android:gravity="left|top"
            android:inputType="textMultiLine" >
            <requestFocus />
        </EditText>
    </android.support.design.widget.TextInputLayout>
    <RelativeLayout 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"
        android:orientation="vertical">
        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab_main"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_marginBottom="16dp"
            app:backgroundTint="#FFF62F5E"
            android:layout_marginRight="16dp"
            android:clickable="true"
            android:src="@drawable/plus"
            app:elevation="4dp" />
    </RelativeLayout>
</LinearLayout>

1 个答案:

答案 0 :(得分:1)

只需输入此代码

<LinearLayout 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"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:local="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/primary"
        local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">


        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/input_layout_password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"

                    android:paddingTop="25dp">

                    <EditText
                        android:id="@+id/DatePicker"
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:layout_marginLeft="20dp"
                        android:layout_marginRight="20dp"
                        android:layout_weight="15"
                        android:background="#FFF8F9FA"
                        android:clickable="true"
                        android:drawableRight="@drawable/calendar_month"
                        android:focusableInTouchMode="false"
                        android:hint="Select Date"
                        android:inputType="text"
                        android:textColor="#FF808080" />
                </android.support.design.widget.TextInputLayout>

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/Indberettet"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingTop="5dp">

                    <EditText
                        android:id="@+id/IndberettetePicker"
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:layout_marginLeft="20dp"
                        android:layout_marginRight="20dp"
                        android:layout_weight="15"
                        android:background="#FFF8F9FA"
                        android:clickable="true"
                        android:focusableInTouchMode="false"
                        android:hint="Indberettet på Vegne af en Anden"
                        android:inputType="text"
                        android:textColor="#FF808080" />
                </android.support.design.widget.TextInputLayout>

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/input_layout_password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <EditText
                        android:id="@+id/IndberettetePicker"
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:layout_marginLeft="20dp"
                        android:layout_marginRight="20dp"
                        android:layout_weight="15"
                        android:background="#FFF8F9FA"
                        android:clickable="true"
                        android:focusableInTouchMode="true"
                        android:hint="Hændelses type"
                        android:inputType="text"
                        android:textColor="#FF808080" />
                </android.support.design.widget.TextInputLayout>

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/input_layout_password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingLeft="20dp">

                    <EditText
                        android:id="@+id/editText1"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:ems="10"
                        android:gravity="left|top"
                        android:hint="Hændelsesbeskrivelse"
                        android:inputType="textMultiLine"
                        android:minLines="3">

                        <requestFocus />
                    </EditText>
                </android.support.design.widget.TextInputLayout>

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/input_layout_password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingLeft="20dp">

                    <EditText
                        android:id="@+id/editText3"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:ems="10"
                        android:gravity="left|top"
                        android:hint="Hændelsessted / Adresse"
                        android:inputType="textMultiLine"
                        android:minLines="3">

                        <requestFocus />
                    </EditText>
                </android.support.design.widget.TextInputLayout>

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/input_layout_password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingLeft="20dp">

                    <EditText
                        android:id="@+id/editText3"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:ems="10"
                        android:gravity="left|top"
                        android:hint="Forebyggende foranstaltninger"
                        android:inputType="textMultiLine"
                        android:minLines="3">

                        <requestFocus />
                    </EditText>
                </android.support.design.widget.TextInputLayout>


            </LinearLayout>
        </ScrollView>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab_main"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="16dp"
            android:clickable="true"
            android:src="@drawable/plus"
            app:backgroundTint="#FFF62F5E"
            app:elevation="4dp" />
    </FrameLayout>

</LinearLayout>