Using shape in Android

Source: Internet
Author: User
Tags dashed line

Original link http://blog.csdn.net/psmmsp/article/details/51353172
The properties of shape are:
- corners– Fillet
- padding– inner margin
- Size (height, width) – Set width height
- stroke– Strokes
- gradient– Gradient
- solid– Fill

Introduced separately

1.corners– rounded Corners

<corners    android:radius="10dp"    android:bottomLeftRadius="10dp"    android:bottomRightRadius="10dp"    android:topLeftRadius="10dp"    android:topRightRadius="10dp"    ></corners>

Setting radius= "10DP" is equivalent to: set the left and right to 10DP respectively, vice versa

2.padding– Inner margin

<padding    android:left="1dp"    android:top="1dp"    android:right="1dp"    android:bottom="1dp"/>

This is a good understanding, no explanation.

3.size (height, width) – Set width height

<size android:height="10dp" /><size android:width="100dp"/>

4.stroke– Strokes

<stroke    android:color="@color/red_200"    android:width="2dp"    android:dashWidth="1dp"    android:dashGap="1dp"    ></stroke>

Width: The breadth of the stroke; color: The dark color of the stroke; Dashgap: The default 0DP is solid, not 0 dashed, and the value represents the distance between virtual points; Dashwidth: Controls the width of the virtual point when it is a dashed line
5.gradient– Gradient

 <gradient        android:centerColor="#ff00ff00"        android:endColor="#ff0000ff"        android:startColor="#ffff0000"        android:gradientRadius="100dp"        android:type="radial" />

StartColor set start color, EndColor end color, centercolor middle color
When type is radial expressed as a gradient centered around the Gradientradius radius,


When type is linear, Gradientradius is invalid and the result is:

6.solid– Fill

<solid android:color="@android:color/white"></solid>

OK, welcome advice.
Personal GitHub

Using shape in Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.