Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
In this blog, I will show you how to make different shapes in android.
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.
res/drawable/your_shape.xml
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.
"rectangle": A rectangle that fills the containing View. This is the default shape.
"rectangle":
"oval": An oval shape that fits the dimensions of the containing View.
"oval":
"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.
"line":
"ring": A ring shape.
"ring":
In Java: R.drawable.your_shape In XML: @[package:]drawable/your_shape
R.drawable.your_shape
your_shape
@[package:]drawable/your_shape
Create the file named circuler_shape.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="@color/md_red_600" /> <padding android:bottom="5dp" android:left="5dp" android:right="5dp" android:top="5dp" /> </shape> 12345678910 <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="@color/md_red_600" /> <padding android:bottom="5dp" android:left="5dp" android:right="5dp" android:top="5dp" /></shape> and this XML layout applies to a Textview: <TextView android:id="@+id/sale" android:layout_width="35dp" android:layout_height="35dp" android:background="@drawable/circuler_shape" android:gravity="center" android:text="SALE" /> 1234567 <TextView android:id="@+id/sale" android:layout_width="35dp" android:layout_height="35dp" android:background="@drawable/circuler_shape" android:gravity="center" android:text="SALE" /> For programmatically: TextView saleTv = (TextView)findViewByID(R.id.sale); tv.setBackgroundResource(R.id.circuler_shape); 12 TextView saleTv = (TextView)findViewByID(R.id.sale);tv.setBackgroundResource(R.id.circuler_shape);
Create the file named circuler_shape.xml
and this XML layout applies to a Textview:
For programmatically:
Source:
https://developer.android.com/
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.