Custom shape design for button in android - android

I'm trying to create a shape for Button that would have one side round and other right side slop , the actual image and a shadow.
I'm tried alot but i'm not understand how to draw it and how to draw shadow for same.
Thanks in advance.

Design the shape whatever you want in any designing tool, export it as SVG. Then, in android studio right click on "drawable" folder -> new vector asset, then choose the exported SVG file from your local disc.
Now you can able to set the created drawable as button background.

Here is the information about custom buttons. In a different approach you can use canvas and onClickListener.

Related

How to make android app icon display correctly?

I have tried changing different settings, using different image sizes and using different image shapes but nothing has worked. Do I need to add a version with rounded corners to my android studio file?
Right click on drawable folder > new > image asset.
In the asset studio it will automatically generate the app icon shape, you just have to pick your transparent logo on the foreground layer and pick the white color on the background layer. So no need to provide rounded corners version

How to cut out a triangle in a circle button using Kotlin in android studio?

I'm going to design a layout which includes a circle button. There is a triangle in centre of the circle. The background of the circle should be transparent but the background of triangle should be the main background (in fact I wanna cut out a triangle from a circle button). Do you have any idea how to implement that using Kotlin?
image is attached:
button image
Keep in mind thay Android Studio doesn't have an image editor inside it. The easiest way to achieve it is getting the icon vector and importing it to android studio.
When It comes to design, there are some tools that helps devs. Take a look at this material icon database and search for "play":
https://materialdesignicons.com/
Download the SVG and import it to android studio.
An alternative is, inside android studio, right-click at res>drawable folder. Import Vector Asset. Android studio has some ready-to-use icons. You'll may find some there too.

Android Custom shaped Button

I want to create a custom shaped button like below in android with xml(I know I can do it with the image but it isn't one of my options),how to do this?
I started with the rectangle shape and then tried to play with the corners in negative way to make the right side raise but I was unsuccessful.
You should use a 9-patch (resizable drawable) as your button background, read this.

how to create arrow from xml code

In my project i need to create the frames, lines and all the shapes required from the drawable folder. I could draw a rectangle and frame and all from drawable. But the problem comes when i need to create arrows from the drawable folder.
Please help me to draw the up arrow and down arrow as shown in the images in the drawable folder.
You cannot draw complex shapes currently with the builtin tools android has. ShapeDrawable lists all the possibilities you have for now.
Why don't you just create different sizes of the arrow in png (ldpi, mdpi, hdpi), and use those? That is the recommended way.
If you want to do custom things, you either should look into SVG, or draw your own.

Custom Map markers and custom backgrounds

I am trying to get the images to have transparent backgrounds so the map is not blocked by a square marker with an image in it. What image editor and what settings should I use to get this to work?
I am trying to do some custom backgrounds for buttons and the same problem comes up: I get square corners and a background that does not scale with the buttons.
I think this all part of the same problem: I am not using the right tool with the right settings to create the images. I must be misinterpreting the documentation and examples that talk about a white border around the image and a black line along the top and left side for the expandable button background.
Here's a quick way to reproduce the problem:
Follow the directions to create the MapView program as described on:
http://developer.android.com/resources/tutorials/views/hello-mapview.html
For the icon I first used the image copied from the page:
Next I edited the picture in Microsoft Paint, and cut off the little guy's antennae. I'm not cruel and no real androids were harmed in that experiment. I surrounded the new picture with a pixel thick border of white, copied from the border that was around the rest of the image, and then copied the black that was there as well in the void areas of the image, outside the border.
I saved the image as myandroid.png and copied the file to the layout folder. Pointed the activity to the new pic and ran the program.
The image was displayed with a full square background and shadow, not the android shaped image and shadow that was there when the original image was used.
Custom Button background:
Follow the directions for the Relative Layout example at:
"http://developer.android.com/resources/tutorials/views/hello-relativelayout.html"
Next, I created an image to expand as a background for the button called backbutton.png. It too is surrounded by a white border and black filled on the corners, the top and one side per documentation I found in "Android Programming Tutorials" on page 298.
The background does not expand, nor do the corners round.
I wish I could show you screenies of what I have.
How do you create the images for the custom backgrounds and the images for the custom map markers and buttons? I need to know what image editor to use and the file attributes to set, so the images expand and display with the proper void spaces in them.
Thank you in advance.
You used MSPaint to save the image did you define the transparent color?
should in Image > Attributes
To create custom backgrounds for buttons and other widgets that can change their size at runtime, you should create NinePatch images. The tool you should use is draw9patch and is available with the Android SDK.

Categories

Resources