I'm trying to make gradient background that placed only bottom right.
(Sorry for images because I don't have enough rep for inline)
https://i.stack.imgur.com/ebgWn.jpg
First, I made radial gradient but not perfect
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:centerX="0.9"
android:centerY="1"
android:endColor="#00000000"
android:gradientRadius="40%p"
android:startColor="#BF000000"
android:type="radial" />
</shape>
It looks like:
https://i.stack.imgur.com/JOqFf.jpg
Then, I made linear gradient but still not perfect.
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="315"
android:endColor="#CD000000"
android:startColor="#00FFFFFF"
android:type="linear" />
</shape>
https://i.stack.imgur.com/a0y9C.jpg
Because gradientRadius parameter doesn't work with linear gradient. Are there any starting/ending point parameter for this gradient? Thanks for help!
Best i have tried with
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:centerX="0.8"
android:centerY="1"
android:endColor="#00000000"
android:gradientRadius="80%p"
android:startColor="#BF000000"
android:type="radial" />
And then Wrap your TextView and Tick Icon together inside a layout and set the above background to it..
If you want the exact same effect as you provided in image then you better use a Image or vector file for it .. But the approach will be same setting the background to only Wrapped layout not the Root.
Related
I'm trying to create a drawable overlay shape control that will basically have a solid WHITE box at the top and then the remaining segment of the screen will have a gradient from a solid white down to a translucent white. We use this to lay over a background image to create a solid white area on top and then fading into the a background image towards the bottom.
Using this code it gets basically what I want, except I want a true solid white area under the Company Logo area (sorry I had to blank out the Company Logo and the App Name in the screen shot) with the gradient starting below the solid white.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="270"
android:startColor="#ffffffff"
android:centerColor="#00ffffff"
android:endColor="#00ffffff"
android:centerY="0.6"
android:type="linear" />
</shape>
</item>
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#ffffffff"
android:centerColor="#ffffffff"
android:endColor="#00ffffff"
android:centerY="-0.17"
android:gradientRadius="100%p"
android:type="radial" />
</shape>
</item>
</layer-list>
Which produces a display similar to this:
But I really want a more solid white area to be directly under the Company Logo area and then with the gradient starting after that point. But you can see that the gradient is starting at the top of the screen.
I've tried to do something like the following but it's not working. Adding the first item in the list does give me a solid area at the top, but for some reason that I'm probably just not understanding is that the top item fills in the entire screen with the solid white color. I tried moving that first item to the bottom but that still gave me the full solid white screen.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item >
<shape
android:shape="rectangle">
<size android:height="100dp" />
<solid android:color="#ffffffff"/>
</shape>
</item>
<item android:top="100dp" >
<shape
android:shape="rectangle">
<gradient
android:angle="270"
android:startColor="#ffffffff"
android:centerColor="#00ffffff"
android:endColor="#00ffffff"
android:type="linear" />
</shape>
</item>
<item android:top="100dp" >
<shape
android:shape="rectangle">
<gradient
android:startColor="#ffffffff"
android:centerColor="#ffffffff"
android:endColor="#00ffffff"
android:centerY="-0.17"
android:gradientRadius="100%p"
android:type="radial" />
</shape>
</item>
</layer-list>
Can anyone tell me what I'm doing wrong or give me a better way to do this.
Just for additional information. The actual image is being applied to the background of the base LinearLayout view. Then another view is overlayed on top of the base view with this drawable set as the background on it's LinearLayout so it acts as an overlay mask on top of the background image.
I appreciate any help I can get on this.
You can add two Linear Layouts children to one Relative Layout parent. Have the top Linear Layout have the background of white, and the bottom one your gradient.
Hi I'm trying to make a drawable which looks like a small vertical line with a circle attached to the bottom of it. I am trying to figure out if creating such a shape in a single xml file is possible (I know I could probably place two shapes on top of each other but I'm trying to avoid doing that)
Here's what I have so far:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/line">
<shape
android:shape="line"
>
<stroke
android:width="2dp"
android:color="#000000" />
<size android:height="12dp"/>
</shape>
</item>
<item
android:top="5px"
android:id="#+id/circle">
<shape
android:shape="oval"
android:useLevel="false"
android:innerRadius="5dp"
android:thickness="2dp"
>
<solid
android:color="#color/silver_status"
></solid>
<stroke
android:color="#color/silver_status"
android:width="1dp"
/>
</shape>
</item>
</layer-list>
This layers the two images on top of each other (I think) but what I really want is for them to be on top of each other
Anyone know if this is possible/how it can be done?
I ended up solving this simply by using the individual shapes within a linear layout to achieve the affect. Not exactly what I wanted but definitely does the job just fine.
I have developed a listView for my app. My UI is simple flat UI, here is a snapshot:
when I searched internet for better interfaces I found this for example:
As you see in this sample, background colors have shadows at the bottom. Is there a way that I can color my Layout background like this? Thanks in advanced.
In order to achieve a shadow effect I'd guess that it's better to use a layer-list with two items, one with the solid color and the second item would be a gradient coming from transparent to a black color with an alpha value.
Here's how this would look like (needs to be placed in res/drawable/):
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#ff33b5e5" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<gradient
android:angle="-90"
android:endColor="#90000000"
android:startColor="#android:color/transparent" />
</shape>
</item>
</layer-list>
Doing it this way, you won't need to "search" for a darker color of your solid color all the time.
Output would look like this:
Create an XML file and named it as "gradient_effect" in Res -> Drawable folder and put below code in it
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#a0a0a0"
android:endColor="#f5f5f5"
android:angle="0"
/>
Now use this file as a background in any of your layout as you can get is like
android:Background= "#Drawable/gradient_effect"
Set above line as an attribute for any of you view or layout in xml file
This can help too!
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient
android:angle="90"
android:endColor="#A2000000"
android:startColor="#android:color/transparent" />
</shape>
</item>
I'm trying to add 3d effect as background of TableRow using gradient, is there a way to make it appear like a stair 3D effectlike that:
And wanna my text appear like a box placed on each stair.
Currently i'm using:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#77F3AE1B"
android:centerColor="#77F3AE1B"
android:endColor="#77AA893C"
android:angle="270"/>
<padding android:left="4dp"
android:right="4dp" />
<corners android:radius="4dp" />
</shape>
but don't look really as 3d effect, i've try to use image background but have lots of problems bcs of screens dimentions and orientation!
How do I make a gradient image in Android, like this photo?
I tried this, Hope it will work for you
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:type="radial" android:gradientRadius="250"
android:startColor="#E9E9E9" android:endColor="#D4D4D4" />
</shape>