androidandroid-layoutbackgroundaero-glass

glass like background color in android


I am creating an app, where i am creating a layout like this image,

glassy Look

but i want that the upper part of the image should be of some other color, but the color should be transparent, so that the background should be visible from that color. I am using a style xml for this,

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
     <stroke android:width="2dp" android:color="#FFFFFFFF" />
     <gradient android:startColor="#DD000000" android:endColor="#DD2ECCFA" 
            android:angle="225"/> 

    <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" 
     android:topLeftRadius="7dp" android:topRightRadius="7dp"/> 
</shape> 

But it is creating a color layout that is not transparent and the background is not visible from this color. suggest some tips to make the color transparent, so that i can attain a glassy look for layout.


Solution

  • use this code,

    <?xml version="1.0" encoding="UTF-8"?> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
     <stroke android:width="2dp" android:color="#FFFFFFFF" />
     <gradient android:startColor="#DD000000" android:endColor="#DD2ECCFA" 
            android:angle="225"/> 
    
     <solid android:color="#AA181818" />
    
    <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" 
     android:topLeftRadius="7dp" android:topRightRadius="7dp"/> 
    </shape> 
    

    Add one line your code ,

    <solid android:color="#AA181818" />