How to make 3d effect using gradient android - android

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!

Related

how to make corner based gradient drawable

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.

Custom background for Text View Using Xml drawable file

I want to make a textview background like in the screenshot. I have a xml file that can make rectangular background like in the screenshot but i am not able to do that below corner styling. I dont know what thing can change this.
Here is my xml file that can give a rectangular background to my textview.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke
android:width="1dp"
android:color="#color/orange" />
<solid android:color="#color/orange" />
<padding
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<corners android:radius="5dp" />
</shape>
Your best bet here would be to make a nine-patch image. Roman Nurik has made a really nice nine-patch generator that you can use. Then you just set the image as the background and it will stretch like you think it should.

A beautiful imageview frame and an animation

I'm searching over the Internet a beautiful frame/border to insert for an image in an imageview....i'm not able to find nothing good.
Now I have this code that insert just a black border, but I would like something more impactive and more beautiful.
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<stroke android:width="3dp" android:color="#000000" />
<padding android:left="3dp" android:top="3dp" android:right="3dp"
android:bottom="1dp" />
</shape>
Moreover I would like to implement an animation over this image for example when touched that something happen, like that some information happear or the image increases it size. Can someone suggest me some good idea to implement these two things with some good code or some link!!!
You can add corners tag to give it a look of rounded frame.

Can I get a hold of Button Location Data in my Android Application

In my application, I'm (still) trying to manipulate my Button Views to look the way I want. I'd like to attempt an experiment where I'll draw an Android Rect or RectF in the same location as the (transparent) button to highlight it's appearance.
However, I can't figure out how to get my mitts on that information. The buttons in question are defined in XML, in a Linear Layout, but something inside my Android has to know their sizes and locations. Right?
Any suggestions?
Thanks, R.
You should be able to set a background of the button to a custom xml drawable with the drawable containing only stroke element around the edge.
You will need to create this custom drawable: it would be just a few lines of XML.
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="1dp" android:color="#CCCCCC" />
<corners android:radius="10dp" />
</shape>
Edit: updated to include rounded corners.
This answer is a combination of my poking around and Aleks' suggestion to use a custom drawable. Ultimately, my custom drawable needed more than three lines, but it's still not very big:
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:startColor="#android:color/black"
android:endColor="#android:color/black" />
<stroke
android:width="1dp"
android:color="#cccccc" />
<corners
android:radius="5dp" />
<padding
android:left="4dp"
android:top="2dp"
android:right="4dp"
android:bottom="2dp" />
</shape>
</item>
</selector>
I needed to add all of the other detail to get the custom button to work the way I wanted -- and I'm probably not done, but if anybody is interested, this works pretty well...

Android button styling

I am quite new to Android dev, but not Java dev, so doing the logic behind a button is no issue, but styling it is not as easy as css. I have read a couple tutorials on shapes / styles so I kind of know how to do the custom borders and round corners, but I was hoping to see some really good quality examples, like the buttons on the Twitter app http://i.stack.imgur.com/Gip2s.png or the 'debossed' ones on the facebook app.
What I suppose I am really interested in, are using shadows to create effects. Are these done with images, or can you style this in the app?
thanks
for rounded corners create a shape drawable eg. ronded_corner.xml and the angle must be a multiple of 45 degree
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#SomeGradientBeginColor" android:endColor="#SomeGradientEndColor"
android:angle="225"/>
<corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
</shape>
then set this Background by android:background:#drawable/ronded_corner
Whenever you create the button in the layout just set the background property of the button as XML, Put this XML file in the drawable folder.
sample XML code i will post here. you can modify and learn in that only.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="270"
android:startColor="#B80000"
android:endColor="#900405"
android:type="linear"
/>
<stroke android:width="1dp" android:color="#900405"/>
</shape>
For rounded corner button, define inset as shown below and adjust radius.
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="4dp"
android:insetTop="6dp"
android:insetRight="4dp"
android:insetBottom="6dp">
<ripple android:color="?attr/colorControlHighlight">
<item>
<shape android:shape="rectangle"
android:tint="#0091ea">
<corners android:radius="10dp" />
<solid android:color="#1a237e" />
<padding android:bottom="6dp" />
</shape>
</item>
</ripple>
</inset>
For more information http://www.zoftino.com/android-button

Categories

Resources