Android transparent toolbar over ImageView

I am trying to create a transparent toolbar,

so that it appears on top of a ImageView

, which is defined like this:

<ImageView

    android:layout_width="fill_parent"
    android:layout_height="0px"
    android:layout_weight="8"
    android:scaleType="center"
    android:id="@+id/imageView"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:elevation="0dp"
    />

      

Illustration (blue area - ImageView

):

enter image description here

so it is transparent, but it pushes ImageView

down rather than on top of it.

I also tried to use android:elevation

but it didn't help.

+3


source to share


2 answers


Use frame layout

  <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">

    // Your imageview

  <ImageView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"/>

     //your toolbar


 </FrameLayout>

      



This should help

+3


source


The Toolbar is just a ViewGroup. Therefore, consider the layout as a Relative layout. In Relative layout you have this order: bottom position in the layout, then this view will be considered the highest layer of the layout. Therefore, put your views in the correct order and you will achieve the desired result. Has worked for me many times before.



+4


source







All Articles