Check Mobile App
Read now
Start a Project

How to make different shapes in android

Save

In this blog,
I will show you how to make different shapes in android.

Shape

The shape is the XML Element which is defined in XML. and must be the root element.

The file location is :

res/drawable/your_shape.xml
The filename is used as the resource ID.

The values which define the type of shape,

"rectangle": A rectangle that fills the containing View. This is the default shape.

"oval": An oval shape that fits the dimensions of the containing View.

"line": A horizontal line that spans the width of the containing View. This shape requires the  <stroke>   element to define the width of the line.

"ring": A ring shape.

How to create shapes

  1. Circle:
  2. Rectangle:
  3. Ring:
  4. Line:

How to access

In Java: R.drawable.your_shape
In XML: @[package:]drawable/your_shape

Example:

Create the file named circuler_shape.xml

and this XML layout applies to a Textview:

For programmatically:

Source:

https://developer.android.com/

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.

Osama
Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home