java - ImageView 应该位于所有内容之上,例如 float 操作按钮

标签 java android android-fragments imageview floating-action-button

我的 MainActivity 中有一个 ImageView,它与 float 操作按钮位于相同的位置。 我希望 ImageView 位于所有内容之上,例如 float 操作按钮。 目前它看起来像这样: https://gyazo.com/ee0aca8d5bc5061d3e437e6d71575ee8

ImageView 位于按钮后面。 但我希望它始终位于应用程序中每个网站的前台。

我的activity_main.XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:ads="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:fitsSystemWindows="true"
    android:orientation="vertical">


    <android.support.v7.widget.Toolbar
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/orange"
        android:id="@+id/toolbar"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:title="Tanzverbot Soundboard" />

    <android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:id="@+id/drawerLayout">

        <RelativeLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/containerView">

            <ImageView
                android:id="@+id/fab"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|end"
                android:src="@drawable/tanzit"
                android:adjustViewBounds="true"
                android:maxWidth="50dp"
                android:maxHeight="50dp"
                android:layout_above="@+id/adView"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                android:layout_marginRight="32dp"
                android:layout_marginEnd="32dp"
                android:layout_marginBottom="38dp" />

            <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"
                ads:adSize="SMART_BANNER"
                android:layout_gravity="bottom|end"
                ads:adUnitId="@string/banner_ad_unit_id">
            </com.google.android.gms.ads.AdView>

        </RelativeLayout>



        <android.support.design.widget.NavigationView
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:id="@+id/shitstuff"
            app:itemTextColor="@color/black"
            app:menu="@menu/drawermenu"
            />


    </android.support.v4.widget.DrawerLayout>


</LinearLayout>

最佳答案

尝试交换 ImageViewcom.google.android.gms.ads.AdView。 另外,您可以尝试设置您的 ImageView

android:elevation="10dp"

关于java - ImageView 应该位于所有内容之上,例如 float 操作按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43192702/

相关文章:

java - 使用bean数据源和子报告在JasperReports中生成空白报告

java - 如何以编程方式根据架构验证 JSON 字符串?

android - api 19 的无效资源字符串 - Android

android - 我如何在 ORMLite 中将 "map"作为所有数据库实体扩展的基础对象

android - fragment 是否可以扩展 fragment ?

java - OnClick 用 fragment 替换 RecyclerView 中的 View

java - JInternalFrame 置于前面并聚焦

java - 自定义 View android中的抽象类实例化错误

java.lang.RuntimeException : Unable to start activity ComponentInfo{. .}java.lang.NullPointerException

java - Java中如何不重写子类中的方法?