`
yuanke
  • 浏览: 69452 次
  • 性别: Icon_minigender_2
  • 来自: 临沂
社区版块
存档分类
最新评论

Android:res之shape制作圆角、虚线、渐变

阅读更多

xml控件配置属性

android:background="@drawable/shape"

标签

corners ----------圆角
gradient ----------渐变
padding ----------内容离边界距离
size ------------大小 
solid  ----------填充颜色
stroke ----------描边

 

注意的是corners的属性bottomLeftRadius为右下角、bottomRightRadius为左下角

 

 

shape制作圆角

<Button 
    android:layout_width="160dp"
    android:layout_height="wrap_content"
    android:background="@drawable/button_shape"
    android:text="圆角按钮"
    />
复制代码
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <solid android:color="#fff"/>
    <padding android:top="10px" android:bottom="10px"/>
    <corners android:radius="16px"/>
    <stroke android:width="1px" android:color="#000"/>
</shape>
复制代码

shape制作虚线

没有dashGap属性则为实线

 

<View 
    android:layout_width="match_parent"
    android:layout_height="5px"
    android:layout_marginTop="10dp"
    android:background="@drawable/line_shape"
    />
复制代码
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line" >
    <stroke
        android:dashGap="3dp"
        android:dashWidth="8dp"
        android:width="1dp"
        android:color="#63a219" />
    <size android:height="1dp" />
</shape>
复制代码

shape制作渐变

<View 
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_marginTop="10dp"
    android:background="@drawable/gra_shape"
    />
复制代码
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <gradient
        android:angle="270.0"
        android:endColor="#ffffff"
        android:startColor="#000000" />

</shape>
复制代码
分享到:
评论

相关推荐

    Android源码: 透明圆角Dialog

    &lt;shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" &gt; &lt;solid android:color="#55000000"/&gt; android:angle="270" android:type="linear" android:endColor="#...

    Android实现圆角Button按钮

    本文实例讲述了Android开发圆角Button按钮实现过程,分享给大家供大家参考,具体内容如下 需求及效果图: ...shape xmlns:android=http://schemas.android.com/apk/res/android android:shape=rec

    Android布局实现圆角边框效果

    首先,在res下面新建一个文件夹drawable,在drawable下面新建三个xml文件:shape_corner_down.xml、shape_corner_up.xml和shape_corner.xml,分别是下面两个角是圆角边框,上面两个角是圆角边框,四个角全部是圆角...

    Android实现 Shape属性gradient 渐变效果

    &lt;shape xmlns:android=http://schemas.android.com/apk/res/android&gt; &lt;gradient  android:type=[linear | radial | sweep] //共有3中渐变类型,线性渐变(默认)/放射渐变/扫描式渐变   android:angle=...

    发生器数字时Protel ss SE常见的元件封装表 电阻:RES1,RES2

    电阻:RES1,RES2,RES3,RES4;封装属性为axial系列 无极性电容:cap;封装属性为RAD-0.1到rad-0.4 电解电容:electroi;封装属性为rb.2/.4到rb.5/1.0 电位器:pot1,pot2;封装属性为vr-1到vr-5 二极管:封装属性...

    安卓分别设置每个角的弧度

    &lt;shape xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;!-- 圆角 --&gt; android:radius="20dp" android:topLeftRadius="20dp" android:topRightRadius="20dp" android:bottomRightRadius="0...

    Android实训购物车页面

    -&lt;LinearLayout android:background="@drawable/aaa" android:weightSum="1" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" xmlns:android=...

    Android开发教程之shape和selector的结合使用

    shape和selector是Android UI设计中经常用到的,比如我们要自定义一个圆角Button,点击Button有些效果的变化,就要用到shape和selector。可以这样说,shape和selector在美化控件中的作用是至关重要的。 1.Shape 简介...

    android自定义弹出框

    &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" &gt; &lt;RelativeLayout xmlns:...

    android中ratingbar的简单使用

    &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; android:layout_...

    Android购物车代码

    -&lt;LinearLayout android:background="@drawable/aaa" android:weightSum="1" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" xmlns:android=...

    Android中drawable使用Shape资源

    本文实例为大家分享了...&lt;shape xmlns:android=http://schemas.android.com/apk/res/android android:shape=line&gt; &lt;stroke android:dashGap=3dp android:dashWidth=6dp android:width=1dp android:color=#FF

    this is a res

    android:layout_below="@+id/displayPhoto" /&gt; android:id="@+id/lastPhoto" android:layout_width="100dp" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:layout_...

    Android SubSettings跳转

    &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" &gt; android:key="settings" android:title="@string/settings" &gt; android:targetClass="com.android.settings.Settings" ...

    androidlayout-marginBottom的值为负数.docx

    xmlns:android="http://schemas.android.com/apk/res/android"&gt;  android:layout_width="fill_parent"  android:layout_height="46.0dip"  android:layout_marginBottom="-1.0dip"  android:src="@drawab

    Android按钮美化样式的实现代码

    &lt;shape xmlns:android=http://schemas.android.com/apk/res/android android:shape=rectangle&gt; &lt;!--设置背景色--&gt; &lt;solid android:color=#7457ED&gt; &lt;!--设置圆角--&gt; &lt;corners and

    ANDROID实验报告组件布局.pdf

    Android 开发 (实验五) 实验题目:... 二、实验内容 组 件 布 局 有 : LinearLayout 、 TableLayout 、 FrameLayout 、 RelativeLayout 三、实验步骤 1、用表格布局完成登录界面 &lt;TableLayout xmlns:android=...

    android实验2界面设计:基本组件.doc

    西 安 邮 电 大 学 (计算机学院) 课内实验报告 实验名称: 界面设计:基本组件 专 业: 网络工程 班 级: 姓 名: 学 号: 指导教师: 日 期: 2017年4月20日... 编写布局代码,如下 &lt;LinearLayout xmlns:android = ...

    android shape实现阴影或模糊边效果

    layer-list xmlns:android=http://schemas.android.com/apk/res/android&gt; &lt;!-- 边 --&gt; &lt;shape android:shape=rectangle&gt; &lt;padding android:bottom=2dp android:left=2dp android:rig

    Android 加载动画的实现

    xmlns:android="http://schemas.android.com/apk/res/android" android: &lt;item android:duration="130" android:drawable="@drawable/image_loading_01"&gt; &lt;item android:duration="130" android:drawable="@...

Global site tag (gtag.js) - Google Analytics