3

I'm trying to have a transparent toolbar,

such that it will be shown on top of an ImageView which is set as follow:

<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 is an ImageView):

enter image description here

so, it is transparent, but it pushes the ImageView down, instead of being on top of it.

I also tried using android:elevation, but it didn't help.

Community
  • 1
  • 1
nobatlinux
  • 347
  • 2
  • 10

2 Answers2

4

Toolbar is just ViewGroup. So consider making layout like Relative layout. In Relative layout, u have such order : the lower position in layout code, then this view would be considered as highest layer of layout. So put your views in correct order and you will achieve desired result. Worked for me many times before.

kamilmasta
  • 129
  • 7
4

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

Prakhar
  • 710
  • 6
  • 24