nobatlinux
nobatlinux

Reputation: 357

Android transparent toolbar over an ImageView

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.

Upvotes: 3

Views: 2484

Answers (2)

Prakhar
Prakhar

Reputation: 710

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

Upvotes: 4

kamilmasta
kamilmasta

Reputation: 129

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.

Upvotes: 4

Related Questions