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

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

一、shape drawable

xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="rectangle">    android:radius="3dp"/>    android:angle="270"              android:endColor="#cccccc"              android:startColor="#acacac"/>
二、state list drawable

xmlns:android="http://schemas.android.com/apk/res/android">android:drawable="@drawable/button_shape_normal"      android:state_pressed="false"/>    android:drawable="@drawable/button_shape_pressed"          android:state_pressed="true"/>
xmlns:android="http://schemas.android.com/apk/res/android">android:color="#ffffff"      android:state_pressed="false"/>    android:color="#556699"          android:state_pressed="true"/>
三、layer list 与 inset drawable

xmlns:android="http://schemas.android.com/apk/res/android">            android:shape="rectangle">            android:radius="5dp"/>            android:angle="90"                android:centerColor="#303339"                android:centerY="0.05"                android:endColor="#000000"                android:startColor="#000000"/>                        android:drawable="@drawable/button_shape"               android:insetBottom="5dp"/>    
效果:出现阴影

更多相关文章

  1. 【Android(安卓)工具类】常用工具类(方法)大全
  2. android-屏幕分辨率那点事儿
  3. android:duplicateParentState属性解释
  4. DisplayMetrics简介
  5. Android(安卓)布局 屏幕适配
  6. Android开发——Android手机屏幕适配方案总结
  7. Android显示圆角图片,可指定图片某几个角为圆角
  8. Android中dip, dp, px, sp之间的区别
  9. Android(安卓)获取屏幕尺寸与密度

随机推荐

  1. css盒模型以及如何计算盒子的宽度
  2. Visual Studio 2019 C++使用log4cplus
  3. 深入了解typeof与instanceof的使用场景及
  4. 你真的知道typeof null的结果为什么是‘o
  5. 推荐!5款Linux常用桌面环境
  6. css详解position五种属性用法及其含义
  7. 深入了解JavaScript中基于原型(prototype)
  8. 一文学会怎样设置AppleWatch手表自动解锁
  9. css详解background八大属性及其含义
  10. 一篇文章带你初步了解—CSS特指度