Create a 3d shaped button in android -
I'm trying to create a button similar to seeing the round button here -
(Each button looks like this is inside a disassembled section) I had to put the button in a circle background and end up with a slight gradient - though I found this result -
(I can upload my code once) How do I see this So I?
Try this code I'm able to create an image that looks like this
which is similar to the first button that you link to , Using the following code.
File: res / drawable / button.xml The file should be in the shape of the layers In your main layout, add a You can click in the Java code by clicking & lt; Layer-list & gt; to use.
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Layer-list xmlns: android = "http://schemas.android.com/apk/res/android" & gt; & Lt ;! - External boundary / Shade - & gt; & Lt; Items & gt; & Lt; Size Android: shape = "oval" & gt; & Lt; Size Android: width = "200dp" Android: height = "200dp" /> & Lt; Shield Android: Angle = "90" Android: startColor = "# f4f4f4" Android: EndColor = "#B 9B 9B 9" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt ;! - Inset - & gt; & Lt; Item android: top = "1dp" Android: left = "1dp" Android: right = "1dp" Android: bottom = "1dp" & gt; & Lt; Size Android: shape = "oval" & gt; & Lt; Shield Android: Angle = "90" Android: startColor = "# dcdcdc" Android: endColor = "# c9c9c9" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt ;! - Inside border / shadow - & gt; & Lt; Item android: top = "15dp" Android: left = "15dp" Android: right = "15dp" Android: bottom = "15dp" & gt; & Lt; Size Android: shape = "oval" & gt; & Lt; Shield Android: Angle = "90" Android: startColor = "# 8c8c8c" android: endColor = "# cbcbcb" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt ;! - main button - & gt; & Lt; Item android: top = "16dp" Android: left = "16dp" Android: right = "16dp" Android: bottom = "16dp" & gt; & Lt; Size Android: shape = "oval" & gt; & Lt; Solid Android: color = "# ffffff" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt ;! - Button image - & gt; & Lt; Item android: top = "70dp" Android: left = "70dp" Android: right = "70dp" Android: bottom = "70dp" & gt; & Lt; Size Android: shape = "rectangle" & gt; & Lt; Solid Android: Color = "# 3b88c2" /> & Lt; Corners Android: Radius = "20dp" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt; Item android: top = "75dp" Android: left = "75dp" Android: right = "75dp" Android: bottom = "75dp" & gt; & Lt; Size Android: shape = "rectangle" & gt; & Lt; Solid Android: color = "# ffffff" /> & Lt; Corners Android: Radius = "20dp" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt; Android: Top = "80 DP" Android: Left = "80 DP" Android: True = "80 DP" Android: Below = "80 DP" & gt; & Lt; Size Android: shape = "rectangle" & gt; & Lt; Solid Android: Color = "# 3b88c2" /> & Lt; Corners Android: Radius = "20dp" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt; / Layer-list & gt;
ImageView which will display this image.
& lt; ImageView Android: src = "@drawable / button" />
OnClickListener and then click
ImageView .
Comments
Post a Comment