自定义控件

1、自定义ProgressBar


  • 这个默认是不会旋转的,所以直接在外面加了一个旋转动画。
    custom_progress.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="360" >

    <shape
        //圆环的内部的半径
        android:innerRadius="12dp"
        //圆环
        android:shape="ring"
        //圆环的厚度
        android:thickness="3dp"
        //去掉 progressBar自带的效果
        android:useLevel="false" >
        <gradient
            //中间的渐变色
            android:centerColor="#3f00"
            //开始的颜色
            android:endColor="#f00"
            //结束的颜色
            android:startColor="#fff" />
    </shape>

</rotate>
  • 在布局文件中引用。
<ProgressBar
            android:id="@+id/pb_progress"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"  
            //引用自己自定义的progressBar            android:indeterminateDrawable="@drawable/custom_progress"
            android:layout_gravity="center"
            android:visibility="invisible" />

2、自定义图片边框


  • 图片的边框,可以自己随意设置
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <stroke
        android:width="1dp"
        android:color="@color/bg_btn_cancel_color" />

    <padding
        android:bottom="1dp"
        android:left="1dp"
        android:right="1dp"
        android:top="1dp" />

    <corners android:radius="3dp" />

</shape>
  • 运用
<ImageView
             android:id="@+id/iv_takewaiting_img"
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:scaleType="fitXY"
             android:background="@drawable/bg_contains_frame" />
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值