I'm trying to bring out a glossy xml drawable gradient as a background to a layout. I am already using the start color and end color boring linear gradient.
<item>
<shape>
<gradient
android:angle="90"
android:startColor="#242424"
android:endColor="#4e4e4e"
android:type="linear" />
</shape>
</item>
Is there any way to control its range of flow? Please some one help.
Edited:
Ok, I have done a little hack around method to get a nice glossy looking title bar,
Linear Layout (with a gradation - drawable background, specifying all
the start and end color values separately) Over this are the icons, (I
used Image buttons with transparent BG), and over this another Relative Layout (with may
be a drawable gradient or a fixed, grey color - for glossiness -
android:background="#20f0f0f0" ) Here 20 is defining the Alpha value.
P.S, This might not be a correct work around, but I'm quiet satisfied with this because switching themes according to clients needs is much faster when compared to 9 patch PNG files (hey, BTW this is just my opinion on it)
And this link is so informative on this,
you cant control its range of flow but instead you can use another property centerColor.
you should try the center color Property in gradient for glossy background.
i used this in my application .
<gradient
android:startColor="#FFF7F7F7"
android:centerColor="#FFCECFCE"
android:endColor="#FFBEBEBE"
android:angle="270"/>
hope this will work for you
Related
So I have some imageviews with a title which is barely visible if the image uploaded is for example white on the bottom because of the white title text. Now our designer told me to make a gradient with 0 percent at the top and 70 percent on the bottom (alpha). Now with colors and stuff I already figured it out but I just can not seem to find a way to do it with alpha.
Is there anyone who can help me out here?
I've been searching stackoverflow for quite some time but none of the topics resolved my issue so far.
So far I have tried the following:
<gradient
android:angle="270"
android:endColor="#80000000"
android:startColor="#null"
android:type="linear"/>
but that didn't turn out to be correct and the fact that my designer told me to do it like I am asking in the question above makes me limited in my options.
Any help would strongly be appreciated!
Since android uses #SRGB color space, 70% alpha is approx. B3.
Try this:
<gradient
android:angle="270"
android:endColor="#B3000000"
android:startColor="#00000000"
android:type="linear"/>
I have defined gradient drawable for my app's navigation drawer's header,
side_nav_bar.xml:
<gradient
android:centerColor="#color/ColorTwoBackground"
android:endColor="#color/ColorTwoForeground"
android:gradientRadius="400"
android:startColor="#color/ColorTwoBackground"
android:type="radial" >
</gradient>
However, it looks as intended only on some devices. On other devices it looks bad.
As you can see in the last image logo loses its contrast...
I want to change it to appear identical or even closely the same on different screens. Probably gradientRadius value does the biggest impact but I have tried other values and "400" seemed to be optimal. Maybe it is possible to determine it programmatically?
I want to do intricate borders in my android popups like I see on the ipad.
example:
What I see here is a thick gradient blue border with alpha transparency at the top. As well as a drop shadow extending further from the background.
In android I've tried using shape objects for doing semi intricate backgrounds. This is just a white border.
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="#303030"/>
<stroke
android:width="1dip"
android:color="#ffffff"
/>
</shape>
but these are limited in that they can't accept images as variables here. I guess it would be awfully complex to do these kind of borders in Android. Like perhaps make a relativelayout or tables with the views having the pieces of the background. Kind of like an HTML layout.
Is there a better way to do complex and intricate borders in android? I'd like to make a polished skin kind of like how iOS has that one default that has a uniform aesthetic for iOS.
Yes it is complicated, but the good thing is you can reuse the layout you draw for all the components in your application, so you basically only have to do it once for each "style".
Here are a few pointers in which I've learned a lot about styling Android:
http://blog.donnfelker.com/2011/08/01/android-rounded-corners-with-a-beveldrop-shadow/
http://blog.stylingandroid.com/archives/378
Custom ImageView with drop shadow
Android: Using linear gradient as background looks banded
And here is the 9-patch image I use for drop-shadow (I think it's taken from one of the posts above)
I want to put two images together (a nine-patch image with icon), So that icon size does not change.
I designed nine-patch image but i don't match these images together.
Is there anyone who can help me?
You can use the android layer list drawable. This allows to stack layers on top of each other. The first layer can hold the nine patch image and the second layer can hold the icon which wont be stretched.
This is how it would look like
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/wp_tabbuttonstrip"/>
<item>
<bitmap android:src="#drawable/wp_dashboard_icon"
android:gravity="center"/>
</item>
</layer-list>
You will need to specify the size of the view, wrap content might not give the desired results.
I am trying to achieve from code the following: (can't post images unfortunatelly)
A rectangle with rounded corners, with an emboss effect (the light comes from top left corner).
In the middle there is a circle engraved in the rectangle. Imagine a water surface, and a drop of water hits the surface. It creates a dent in the surface. That circle is also painted with some linear gradient.
The problem is I could only use the EmbossMaskFilter from Android to raise the surface, to make it closer to the user eye, but I don't know how to implement the opposite.
Anyone can help me with that?
Thank you very much.
Use a composite drawable, or drawables in layers.
To create a drawable with rounded corners and a gradient within, use something like this:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="10dp"/>
<gradient android:startColor="#color/gradientstart" android:endColor="#color/gradientend" android:angle="315"/>
</shape>
Create two such drawables and put them on top of each other to create the required effect.
Unless you use a pretty good number of layer-list items as a drawable you probably won't get the effect you are looking for easily with XML drawables. A better solution would be to create a 9-patch image. See how it works at draw9patch.com, which is a tool to create 9 patch images from a standard images.
NinePatch documentation: here.
In case, you still really want to use xml drawables you can still achieve the effect (although performance might take a hit) using a layer-list with multiple gradients stacked ontop of each other.