Android UI效果之繪圖篇(一)
最近準備整理一套關(guān)于UI效果的文章,算是對這段時間的一個總結(jié),主要講Android開發(fā)中的UI效果設計模塊。初步分為一下幾個篇幅:
- Android XML繪圖(Shape、Layer、Selector)
- Android Canvas繪圖(canvas、point、porterDuffXfermode、shader)
- Android 動畫詳解
- Android 自定義控件
今天就當開胃菜,先講講最簡單的xml繪圖,相信這個大家都用的比較熟,這里就當給大家做一個小文檔,當那個參數(shù)配置忘了,便于查閱
一、Shape
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" // 此處可以設置shape的形狀 不設置默認為rectangle android:shape=["rectangle"|"oval"|"line"|"ring"|] > <!-- 圓角 shape="rectangle"是使用 默認為1dp --> <corners android:radius="xdp" android:topLeftRadius="xdp" android:topRightRadius="xdp" android:bottomLeftRadius="xdp" android:bottomRightRadius="xdp"/> <!-- 漸變 --> <gradient android:startColor="color" android:centerColor="color" android:endColor="color" android:useLevel="boolean" android:angle="integer"http://angle的值必須是45的倍數(shù)(包括0),僅在type="linear"有效 android:type=["linear"|"radial"|"sweep"] android:centerX="integer" android:centerY="integer" android:gradientRadius="integer"/> <!-- 間隔 --> <padding android:left="xdp" android:top="xdp" android:right="xdp" android:bottom="xdp"/> <!-- 大小 寬度和高度 --> <size android:width="dp" android:height="dp"/> <!-- 填充 --> <solid android:color="color"/><!-- 填充的顏色 --> <!-- 描邊 --> <stroke android:width="dp" android:color="color" android:dashWidth="dp" //虛線寬度 android:dashGap="dp"/> //虛線間隔寬度 </shape>
二、Layer
這個用過photoshop的朋友,應該很好理解,用于實現(xiàn)圖層效果
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!-- item1 --> <item> <bitmap android:src="drawable" android:gravity="center" /> </item> <!-- item2 --> <item> <bitmap android:src="drawable" android:gravity="center" /> </item> <!-- item3 --> <item <bitmap android:src="drawable" android:gravity="center" /> </item> </layer-list>
三、Selector
這個常用語Button、CheckBox、Radio等控件中,通過不同的事件切換控件效果
<?xml version="1.0" encoding="utf-8" ?> <selector xmlns:Android="http://schemas.android.com/apk/res/android"> <!-- 默認時的背景圖片--> <item Android:drawable="drawable" /> <!-- 沒有焦點時的背景圖片 --> <item Android:state_window_focused="false" android:drawable="drawable" /> <!-- 非觸摸模式下獲得焦點并單擊時的背景圖片 --> <item Android:state_focused="true" android:state_pressed="true" android:drawable= "drawable" /> <!-- 觸摸模式下單擊時的背景圖片--> <item Android:state_focused="false" Android:state_pressed="true" Android:drawable="drawable" /> <!--選中時的圖片背景--> <item Android:state_selected="true" android:drawable="drawable" /> <!--獲得焦點時的圖片背景--> <item Android:state_focused="true" Android:drawable="drawable" /> </selector>
以上就是Android開發(fā)中的UI效果設計模塊的一部分內(nèi)容,之后還會繼續(xù)更新,希望對大家的學習有所幫助。
相關(guān)文章
Android開發(fā)之模仿微信打開網(wǎng)頁的進度條效果(高仿)
這篇文章主要介紹了Android開發(fā)之模仿微信打開網(wǎng)頁的進度條效果(高仿)的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-07-07Android 自動化測試經(jīng)驗分享 深入UiScrollable
UiScrollable是一個UiCollection(這東西還沒搞懂),我們可以使用它,在可滑動的頁面(水平滑動或上下滑動都可以)上查找我們想要的控件(item)2013-05-05Android自定義Dialog內(nèi)部透明、外部遮罩效果
這篇文章主要為大家詳細介紹了Android自定義Dialog內(nèi)部透明、外部遮罩效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-10-10Android RecyclerView區(qū)分視圖類型的Divider的實現(xiàn)
本篇文章主要介紹了Android RecyclerView區(qū)分視圖類型的Divider的實現(xiàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-04-04詳解Android studio 3+版本apk安裝失敗問題
這篇文章主要介紹了詳解Android studio 3+版本apk安裝失敗問題,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-04-04Android開發(fā)之CheckBox的簡單使用與監(jiān)聽功能示例
這篇文章主要介紹了Android開發(fā)之CheckBox的簡單使用與監(jiān)聽功能,結(jié)合簡單實例形式分析了Android使用CheckBox控件的布局與功能實現(xiàn)技巧,需要的朋友可以參考下2017-07-07