Question

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.

Was it helpful?

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" />

OTHER TIPS

The isuue is solved, thanx rajeshwaran, i have used..

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
     <stroke android:width="1dp" android:color="#FFFFFFFF" />

<solid android:color="#150000A0" />
    <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" 
     android:topLeftRadius="7dp" android:topRightRadius="7dp"/> 
</shape> 

I have just given values instead of AA in solid tag..

<solid android:color="#150000A0" />

Thanx for help.. helped me in understanding the concept of color..

 <solid android:color="#AARRGGBB" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top