Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 浮动动作按钮阻挡横幅_Xml_Android Layout_Xamarin.android - Fatal编程技术网

Xml 浮动动作按钮阻挡横幅

Xml 浮动动作按钮阻挡横幅,xml,android-layout,xamarin.android,Xml,Android Layout,Xamarin.android,我知道这可能是重复的,但我没有在下面提供的链接中找到我的答案。我的问题是很常见的,我猜浮动操作按钮是阻止横幅广告 这是我的xml: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android&

我知道这可能是重复的,但我没有在下面提供的链接中找到我的答案。我的问题是很常见的,我猜浮动操作按钮是阻止横幅广告

这是我的xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    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">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include
        layout="@layout/content_main" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/fab_margin"
        android:layout_gravity="bottom|right"
        app:srcCompat="@android:drawable/myicon1" />
</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/app_bar_main">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="@string/FloatingAd" />


    <com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    app:adSize="BANNER"
    app:adUnitId="@string/myBannerID" />
</RelativeLayout>

但它不符合我的需要,浮动按钮需要在横幅上方留出一些空间

预期产出:


我有个主意你可以用

您可以在浮动按钮弹出横幅之前保存其X和Y位置。然后,您可以获得横幅视图的测量高度和宽度,并添加将浮动按钮Y设置为等于banner.Height+previousX。这应该只是根据需要将浮动按钮移动到横幅视图上方。如果您想在横幅弹出时制作一些替换动画,这种方法也会很有帮助


您应该使用TranslateX和TranslateY来实现更自然的方法。

您能展示完整的xml吗?@LeoZhu MSFT很抱歉我试图修复的回复太晚了。我提供了完整的XML,您可以尝试将FAB按钮放在与AdView相同的布局中。比如,我尝试了这个解决方案,但它错过了我的洞内容页面。这对某些设备有效,对吗?我的意思是,根据屏幕大小,按钮可能与其他设备不同!是的,X和Y是根据设备屏幕大小分配和计算的。就像使用view.GetLocationOnScreen()一样,它会根据您的屏幕提供一个值