Android Drawable Resource學習(十三)、其他的Drawable資源

來源:互聯網
上載者:User

從Drawable的繼承結構上看,還有幾個沒有介紹到。

1、ColorDrawable

ColorDrawable使用很簡單,使用<Color>元素就可以定義一個ColorDrawable,然後再其他的地方使用。

在color.xml檔案中定義:

<?xml version="1.0" encoding="utf-8"?><color xmlns:android="http://schemas.android.com/apk/res/android"     android:color="#00FF00"></color>

在布局中使用:

<TextView        android:layout_width="100px"        android:layout_height="wrap_content"        android:text="測試"        android:background="@drawable/color">    </TextView>

2、ShapeDrawable和PaintDrawable

都是用來繪製Shape的。不能通過xml檔案建立,將在以後的Graphics中學習。

3、AnimationDrawable

用來建立動畫的,因為有的動畫並不是Drawable,所以將他歸為anim Resource。將在以後學習動畫的學習。

4、DrawableContainer

一個協助類,包含了多個Drawable,你可以選中一個拿來使用。你也可以繼承它重寫自己的DrawableContainers。或者直接使用它的某個子類。

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

5、PictureDrawable
將在後面的Graphics中學習到。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.