美文网首页
shape的基本使用

shape的基本使用

作者: 努力深耕Android的小透明 | 来源:发表于2017-12-28 10:55 被阅读5次

    shape与selector相似 ,都在drawable 目录下/ ,可以设置为edittext的backgroud/src .

shape的使用步骤:

  1. res/drawable 新建xml(命名可以shape开头)
  2. xml文件编写
1.<?xml version="1.0" encoding="utf-8"?>
2.<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    android:shape=["rectangle"(矩形) | "oval"(椭圆) | "line"(线性) | "ring"(环形) >

    <gradient
4.    <!-- 渐变色 -->
6.        android:angle="180"
7. //角度  可以改变  ,尽量是45度的倍数
8.        android:centerColor="#0f0"
9.        android:endColor="#00f"
10.        android:startColor="#f00" />


11.    <!-- 内边距 -->
12.    <padding
13.        android:bottom="7dp"
14.        android:left="7dp"
15.        android:right="7dp"
16.        android:top="7dp" />


17.    <!-- 设置圆角  半径越大 圆角越大-->
18.    <corners android:radius="8dp" />


19.    <!-- 填充色 -->
20.    <solid android:color="#FEFED7" />


21.//描边设置直线与虚线
22.    <stroke
23.        android:dashGap="1dp"  //空格的宽度
24.        android:dashWidth="3dp" //实线的宽度
25.        android:width="1dp"  //线的宽度
26.        android:color="#6BB2D6" />
27.
28.<!--     设置最小宽高  10dp  10dp -->
29.    <size android:width="10dp" android:height="48dp"/>
30.
31.</shape>
  1. 使用
    android:background="@drawable/shape_location_edittext"

相关文章

  • shape的基本使用

        shape与selector相似 ,都在drawable 目录下/ ,可以设置为edittext的bac...

  • Shape的基本使用

    有时,我们为了APP中节省空间,在能用颜色替代的地方就不要用图片,而如何将颜色组织成想要的形状及如何为指定的颜色添...

  • android 自定义图形shape的使用

    自定义图形shape的使用 1 使用shape 的好处: 2 自定义shape的步骤: 3 shape子属性 4 ...

  • Android-shape属性

    一、shape属性 1.shape属性基本语法: 1)基本属性 Shape可以定义控件的一些展示效果,例如圆角,渐...

  • shape

    shape属性: shape标签下的基本属性(corners、gradient、padding、size、soli...

  • Android使用Shape实现ProgressBar样式

    使用Shape实现样式 使用Shape中的ring实现,如下布局ring.xml: 使用rotate使之旋转 如下...

  • Android中shape中的属性大全

    Android中常常使用shape来定义控件的一些显示属性,今天看了一些shape的使用,对shape有了大体的了...

  • Android shape使用笔记

    Android中常常使用shape来定义控件的一些显示属性,今天看了一些shape的使用,对shape有了大体的了...

  • 【Android程序开发】shape属性的简介和使用

    目录 1.shape简介 2.shape属性详解 3.shape简单使用 具体操作 一、shape简介 设置sha...

  • shape的使用

    一、简单使用 1、新建shape文件 首先在res/drawable文件夹下,新建一个文件,命名为:shape.x...

网友评论

      本文标题:shape的基本使用

      本文链接:https://www.haomeiwen.com/subject/cdkmgxtx.html