0

I am trying to add a linear layout with rounded corners and blurred background in my app. So far ive managed to give the layout rounded corners but i cant figure out how to give it a blurred background.Ive tried setting an alpha attribute in the xml file but it dosent work. Heres what i want to achieve:

enter image description here

The Drawable resource file:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#fff"/>
<stroke android:width="0.5dp" android:color="#B1BCBE" />
<corners android:radius="160dp"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />

</shape>

The Xml code of the layout:

  <LinearLayout
            android:id="@+id/team_lay"
            android:layout_width="match_parent"
            android:layout_height="95dp"
            android:layout_marginTop="40dp"
            android:background="@drawable/layout_bg"


            android:orientation="horizontal">

        </LinearLayout>

What i have achieved so far:

This

How can i achieve the desired results?

TIA..!!!

Poison_Frog
  • 157
  • 2
  • 11

2 Answers2

1

You can achieve it by create a blur background as a xml file and then set background of your container view to it.

Try my example:

blur_background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape
            android:shape="rectangle">
            <solid android:color="#4CAF50" />
        </shape>
    </item>

    <item>
        <shape
            android:shape="rectangle">
            <solid android:color="#AA000000" />
        </shape>
    </item>

</layer-list>

And your container layout:

<LinearLayout
  android:id="@+id/team_lay"
  android:layout_width="match_parent"
  android:layout_height="95dp"
  android:layout_marginTop="40dp"
  android:background="@drawable/blur_background"


  android:orientation="horizontal">

</LinearLayout>

Hope it help. ^^

Brian H.
  • 1,603
  • 11
  • 16
0

So i fount the solution myself. I changed the transparency of the solid color in the drawable resouce file(as mentioned here https://stackoverflow.com/a/41865518/8175719 ) and it worked.

Poison_Frog
  • 157
  • 2
  • 11