Blurred background using only XML in android

Viewed 1471

I am using FrameLayout for different layers of layout. Here is my code :

<FrameLayout>

  <!-- Bottom layer -->
  <RelativeLayout>
      // some views and viewgroups
  </RelativeLayout>



  <!-- Middlelayer -->
  <RelativeLayout>
      // this layer will be empty.
      // I want to make this layer like frosted glass to get blur effect
  </RelativeLayout>



  <!-- Top layer -->
  <RelativeLayout>
      // some views
  </RelativeLayout>
</FrameLayout>

This is how I want it to look:

enter image description here

I want to make the middle layer act like a frosted glass so that the bottom layer looks blurred. How can I implement it using xml only? (If not possible using only xml please help me with java code)

2 Answers

Android unfortunately doesn't really support blurring natively in the way that e.g. iOS and CSS on the web do.

You can use the alpha attribute in your XML

android:alpha="0.5"

or just a background color in your code

v.setBackgroundColor(0xFF00FF00);

Where v is your Middlelayer

Related