Drawable 的 子类

从Drawable的继承结构上看,还有几个没有介绍到。

1、ColorDrawable

ColorDrawable使用很简单,使用<Color>元素就可以定义一个ColorDrawable,然后再其他的地方使用。

在color.xml文件中定义:

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <color xmlns:android="http://schemas.android.com/apk/res/android"   
  3.     android:color="#00FF00">  
  4. </color>  
在布局中使用:
  1. <TextView  
  2.         android:layout_width="100px"  
  3.         android:layout_height="wrap_content"  
  4.         android:text="测试"  
  5.         android:background="@drawable/color">  
  6.     </TextView>  

2、ShapeDrawable和PaintDrawable

都是用来绘制Shape的。不能通过xml文件创建,将在以后的Graphics中学习。


3、AnimationDrawable

用来创建动画的,因为有的动画并不是Drawable,所以将他归为anim Resource。将在以后学习动画的学习。


4、DrawableContainer

一个帮助类,包含了多个Drawable,你可以选中一个拿来使用。你也可以继承它重写自己的DrawableContainers。或者直接使用它的某个子类。

AnimationDrawable,LevelListDrawable, StateListDrawable都是它的子类。

5、PictureDrawable
将在后面的Graphics中学习到。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值