Drawable一個有趣的屬性:tileMode

轉載:https://www.jianshu.com/p/d41cac1c95d2

tileMode是drawable 資源文件 bitmap的一個屬性, 翻譯的意思是平鋪模式。用法如下:
在drawable目錄下新建一個資源文件 tile_mode_demo.xml
android:src="@drawable/ic_launcher" android:tileMode="mirror">
tileMode 一共有 4種屬性:
mirror,repeat,clamp,disabled

我們現在測試4種屬性的具體效果,將 tile_mode_demo.xml當作一個View的背景

xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.wangyi.demo.MainActivity">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/tile_mode_demo" />

1. mirror:一排排正在照鏡子的機器人 ,在AndroidStudio中預覽的效果如下:

2. repeat:滿屏都是機器人

3. clamp:這種情況下將一個View的background 設置成該bitmap, 最終也只會顯示bitmap自身的大小 (其實這個View的尺寸是佔滿了屏幕的 );

4. disabled:這個表示禁用平鋪模式 和直接將圖片設置成背景是一樣的效果。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章