在做一些有關錄像、拍照的功能時,經常需要用到拍攝按鈕。一般情況下使用UI切圖。
現在,我把它封裝為一個普通的View,使用時,直接引用。
既減少了APK體積,又可以自由定制顏色樣式。同時,還提供了倒計時進度條。
項目地址
基本用法
1. 導入倉庫
maven { url 'https://jitpack.io' }
2. 添加依賴
compile 'com.github.senierr:ShootButton:1.0.4'
3. XML
<com.senierr.shootbutton.ShootButton
app:circleColor="@color/colorAccent"
app:circleWidth="8dp"
app:centerColor="@color/colorAccent"
app:centerMode="roundRect"
app:centerPadding="8dp"
app:centerRectRadius="8dp"
app:progressBgColor="@color/colorPrimary"
app:progressColor="@color/colorPrimaryDark"
app:maxProgress="100"
app:progress="0"
android:layout_width="match_parent"
android:layout_height="match_parent" />
參數說明
參數名 | 說明 | 值 |
---|---|---|
circleWidth | 圓環寬度 | dimension |
circleColor | 圓環顏色 | color |
progressBgColor | 進度條底色 | color |
progressColor | 進度條顏色 | color |
centerMode | 中心圖標類型 | circle/roundRect |
centerColor | 中心圖標顏色 | color |
centerPadding | 中心圖標與圓環間距 | dimension |
centerRectRadius | 矩形圖標圓角半徑 | dimension |
maxProgress | 進度最大值 | integer |
progress | 進度值 | integer |
演示
準備錄制
正在錄制
準備拍照
拍照倒計時
Enjoy it!