android - how to create shadow effect from zeplin - android

I have a project in zeplin and I have many views / layouts with
Shadows
outer
X 0dp Y 0dp
Blur 10dp Shadows 0dp
Color #000000
but I am not sure how to implement this in Android. How to specify blur shadow in Android along with a color? setShadowLayer in Paint is the only way? Most of the time I don't have a paint object though, especially for LinearLayout for example.

Related

Android How to create a Glowing Border or Four side shadow Rectangle Shape Background

I want to fill the background of multiple size (custom width or height) constraint layouts with this design:
Noticed that the outline border is glowing with fading gold color.
I have tried with the following:
Attempt (A) is using of ImageView tag, but not scalable to custom width and height.
Attempt (B) is xml created. But the border color is not fading, isn't the desired result.
Attempt (C) is using 9 patch file. The border radius and corner radius does not seems correct at all. (Would also like to know reason of this)
This is my 9patch file:
May I know if this is even possible to achieve?
Anyone please help.

Android Hexagon shape button having hexagon touch bounds

I want to create a hexagon shape button in android so that it's touch area does not overlaps (on the right) ie.I want heaxagon touch bound not a rectangle touch bound. I tried to use image view but it does not excludes tranparent(shown in blue, left). Is there any clickable object which is defined by xml shape/path. please can anyone show me xml shape/path part for just one button if its possible or any other method.
check out this
<com.github.siyamed.shapeimageview.{ClassName}
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:src="#drawable/neo"
app:siBorderWidth="8dp"
app:siBorderColor="#color/darkgray"/>
Attributes:
siBorderColor border color
siBorderWidth border width in dp
siBorderAlpha alpha value of the border between 0.0-1.0
siStrokeCap border stroke cap type butt|round|square
siStrokeJoin border stroke join type bevel|miter|round
siSquare set width and height to the minimum of the given values
true|false
siShape a reference to an SVG. This is used by ShapeImageView, not
the subclasses of it.
There's no system view that would do custom shapes for you. You need to create custom view: http://developer.android.com/training/custom-views/index.html and in its onTouchEvent() determine if user's tap is inside or outside clickable area and act accordingly.

Draw line with faded ends

Is it possible in Android to programmatically draw a line using a path, such that the middle section is a solid color but both ends fade from that color to transparent? The path will be a series of calculated coordinates.
Yes, use a generic View widget with a drawable that contains a gradient as its background.
Make sure it extends to match_parent in the direction you want it to cut your layout and it's 1px tall or wide in the other dimension.
The gradient should be a simple linear gradient transparent to solid to transparent.
Here is a very nice tutorial.
Update:
The above link is dead, try this one instead.

How to set absolute (not %) position for the center of a shape drawable gradient?

I've got a shape drawable with a radial gradient inside it. The shape is a rectangle, and I'm trying to position the center of the radial gradient near the bottom right corner. I can get it in the general vicinity using the centerX and centerY attributes set to values like 0.98, but I'm dealing with rectangles of different heights (same width), so the taller the rectangle is, the higher the center position is, relative to the bottom right corner.
It seems I can only position the center as a percentage of the view width/height, contrary to the documentation. That is, even without the "%" in the value, it is treated as a percentage.
What I'd like to do is somehow say "put the center 5dp up and to the left of the bottom right corner". Any ideas on how to accomplish that?
You might try use a Layer-List, there you can specify margins of overlaying layer items, which can be drawables.

Gradient for border in Android

I have some text in a relative layout.I know that we can draw a border with curves using stroke and corner in a separate xml.
Is there a way to apply gradient effect for the border constructed with the stroke? or is there any other way to draw a gradient border?
Thanks in advance.
I don't know of a way to do that trivially, but it seems like you could define two shape drawables and combine with a layer drawable. The bottom one would be a rounded corner rectangle with a gradient, the top one would be a slightly smaller rounded corner rectangle of whatever you wanted the interior color to be. The effect should be something like a stroke gradient, although I haven't tried it.

Categories

Resources