Check Mobile App
Read now

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

Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!

Deniel Kerr

Owner and Founder. Opencart

Talk to Sales
Start a Project

    Message Sent!

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

    Back to Home