一、效果图
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/bf503061945b4fa204375897bc864f87.png)
二、自定义样式 attrs.xml
<declare-styleable name="AdCountDownView">
<!--控制广告时间-->
<attr name="AD_Time" format="integer"/>
<!--是否需要显示文字 eg:是3秒 还是3-->
<attr name="If_Need_Text" format="boolean"/>
<!--动画圆的半径-->
<attr name="Radius" format="dimension"/>
<!--控制view是有背景还是没有背景 0:无背景 1 :有背景-->
<attr name="Flag" format="integer"/>
<!--倒计时文字的颜色-->
<attr name="Text_Color" format="color"/>
<!--倒计时文字的大小-->
<attr name="Text_Size" format="dimension"/>
<!--动画圆的颜色-->
<attr name="StrokeCircleColor" format="color"/>
<!--背景圆的颜色-->
<attr name="SolidCircleColor" format="color"/>
<!--动画圆的描边宽度-->
<attr name="StrokeWidth" format="dimension"/>
<!--是否有间隙-->
<attr name="hasGap" format="boolean"/>
</declare-styleable>
三、XML布局
<com.midu.tele.widget.AdCountDownView
android:id="@+id/AdCountDownView"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:Flag="1"
app:Text_Color="@color/white"
app:Text_Size="18sp"
app:SolidCircleColor="#333333"
app:StrokeCircleColor="#9F333333"
app:Radius="40dp"
app:If_Need_Text="false"/>
四、Activity界面设置
AdCountDownView mAdCountDownView = findViewById(R.id.AdCountDownView);
mAdCountDownView.setAdTime(3);
mAdCountDownView.setEndCallBack(this);
@Override
public void animEnd() {
mAdCountDownView.setVisibility(View.INVISIBLE);
}
五、自定义圆形倒计时
import android.animation.