我在我的MainActivity中有一個ImageView像浮動動作按鈕一樣位置。 我希望ImageView高於一切,比如浮動操作按鈕。 目前看起來像這樣: https://gyazo.com/ee0aca8d5bc5061d3e437e6d71575ee8ImageView應該高於一切像浮動動作按鈕
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>
他需要'LinearLayout'有'Toolbar'頂部和內容下方。實際上,如果我沒有錯,'DrawerLayout'本身就會擴展'FrameLayout'。 – Ivan
我在談論containerView –
@LuizFernandoSalvaterra它仍然看起來像這樣https://gyazo.com/9275e291f215d92d5e7f2b8740a3d749 –