android把任何可绘制在屏幕上的图形图像都称为drawable.

XML drawable与像素密度无关,将其放入drawable目录即可。

一、shape drawable

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="3dp"/>
    <gradient android:angle="270"
              android:endColor="#cccccc"
              android:startColor="#acacac"/>
</shape>

二、state list drawable

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_shape_normal"
      android:state_pressed="false"/>
    <item android:drawable="@drawable/button_shape_pressed"
          android:state_pressed="true"/>
</selector>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#ffffff"
      android:state_pressed="false"/>
    <item android:color="#556699"
          android:state_pressed="true"/>
</selector>

三、layer list 与 inset drawable

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <corners android:radius="5dp"/>
            <gradient android:angle="90"
                android:centerColor="#303339"
                android:centerY="0.05"
                android:endColor="#000000"
                android:startColor="#000000"/>
        </shape>
    </item>
    <item>
        <inset android:drawable="@drawable/button_shape"
               android:insetBottom="5dp"/>
    </item>
</layer-list>

效果:出现阴影

XML Drawable相关推荐

  1. 在XML drawable中引用自定义颜色

    == 先看一下一个xml drawable文件,这是一个button的样式. <?xml version="1.0" encoding="utf-8" ? ...

  2. android 图片叠加xml,Drawable子类之——LayerDrawable (图层叠加)

    本文出自 "阿敏其人" 简书博客,转载或引用请注明出处. LayerDrawable对应的XML的根元素是,,它使一种层次化显示的Drawable集合.也就说,可以通过显示由多个D ...

  3. Android开发,使用背景图(xml drawable)为view 设置边框

    Android 开发中,遇到需要设置边框的情景,使用背景图来实现,代码如下: <layer-list xmlns:android="http://schemas.android.com ...

  4. android draw xml,Android使用XML定义渐变的drawable

    Android使用XML定义渐变的drawable Android,xml,drawable,渐变, 不是什么东西都需要美术来做图,利用Android提供的线程的东西,也能作出一下效果出来.当然比较负 ...

  5. Android中读values/xml arrays attrs colors dimens string styles

    本文介绍在Android开发中关于资源文件的存储操作.对于Android资源也是非常重要的, 主要包括文本字符串(strings). 颜色(colors). 数组(arrays). 动画(anim). ...

  6. 在 drawable 资源中使用属性引用的兼容问题

    最近在 Buly 崩溃分析里看到一个之前没见过的异常,异常信息为 Can't convert to color: type=0x2 .详细日志如下: java.lang.RuntimeExceptio ...

  7. Android Drawable - Scale Drawable使用详解(附图)

    一个可以根据自己的level等级, 将指定的Drawable缩放到一定比例 资源放置位置: Eclipse/AS: res/drawable/filename.xml 引用用法: In Java: R ...

  8. 我可以在Android版式中加下划线吗?

    如何在Android布局xml文件中定义带下划线的文本? #1楼 Strings.xml文件内容: <resource><string name="my_text" ...

  9. android 开发数字键盘,Android 仿「微信」自定义数字键盘

    [实例简介] 详情见:http://blog.csdn.net/qq_24867873/article/details/73771817 [实例截图] [核心代码] VirtualKeyboardDe ...

最新文章

  1. Spring Boot 项目瘦身指南,瘦到不可思议!
  2. js创建对象的几种方法
  3. win7下,发布到iis上,本地可以正常访问,远程访问失败
  4. Robust principal component analysis?(RPCA简单理解)
  5. android SharedPreferences实现用户的注册和保存账号密码
  6. 创造思维方法训练_数学思维方法训练课程:每日一题11.24
  7. C#并发编程之初识并行编程
  8. android activity调用Adapter方法刷新列表UI,RecyclerView.Adapter
  9. Flink的ProcessFunction API
  10. PDF Expert mac使用教程:压缩pdf文件大小
  11. 经典C语言学习教程资料
  12. unable to save settings.xml error 拒绝访问
  13. c#元胞自动机_元胞自动机+生命游戏
  14. python爬携程_Python crawler:对携程的航班数据进行抓取,python,爬虫,爬取
  15. win7 计算机定时关机脚本,Win7制作定时关机bat脚本|Win7定时关机程序脚本
  16. Openwrt开发笔记(3)—— 修改路由的网关地址和无线SSID 密码
  17. 人工智能入门参考资料
  18. 网络诊断提示DNS服务器未响应处理
  19. 5-3中央处理器-数据通路的功能和基本结构
  20. Robots SiteMap

热门文章

  1. 如何导出项目到本地_如何在win10中导入/导出组策略设置,这个技巧很实用
  2. 【Elasticsearch】es 7 Failed to parse value [analyzed] as only [true] or [false] are allowed
  3. hortonworks/registry : ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
  4. Flink : Flink JobManager报错 akka.pattern.AskTimeoutException: Ask timed out on
  5. 95-190-040-源码-window-Session Window
  6. struts2+hibernate+spring配置详解
  7. jsp的include两种使用方法
  8. php导入跟引入的区别,PHP7 引入的“??” 和“?:”的区别
  9. C++超详细STL常用算法总结
  10. 【内部资源】这份Java全能手册在字节传疯了!