xml画的简单好看的seekbar带thumb,有二级进度条,以及thumb相关问题

1.效果图

 

 先上规矩,符合大家需求的,就往下看,不符合就右上角。

2.步骤

 2.1 画进度条

      用xml画进度条,包括背景颜色,二级背景颜色,已经加载的颜色。

    bg_seekbar_progress_drawable.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
     <!-- 底部背景 -->
    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="5dp"/>
            <size android:height="3dp" />
            <solid android:color="#505050"/>
        </shape>
    </item>
    
    <!--缓冲进度-->
    <item android:id="@android:id/secondaryProgress" >
        <clip>
            <shape>
                 <corners android:radius="5dp"/>
          		  <size android:height="3dp" />
                <solid android:color="#858585"/>
            </shape>
        </clip>
    </item>

    <!-- 进度背景   00ade6-->
    <item android:id="@android:id/progress" >
        <clip>
            <shape>
                <corners android:radius="5dp"/>
                <size android:height="3dp" />
                <solid android:color="#0485e0"/>
            </shape>
        </clip>
    </item>
 	
</layer-list>

2.2 画一个蓝色的实心圆点

     还是用xml写。yuan.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="oval"
  
     >
     
   <size 
       android:width="20dp"    
       android:height="20dp"
       />
<solid android:color="#0485e0" />

</shape>

2.3 在布局文件使用

 <SeekBar 
         android:progressDrawable="@drawable/bg_seekbar_progress_drawable"
     	        android:id="@+id/seekbar"
     	        android:layout_width="match_parent"
     	        android:layout_height="wrap_content"
     	        android:layout_marginTop="100dp"
     	        android:layout_marginLeft="40dp"
     	        android:splitTrack="false"
     	        android:secondaryProgress="60"
     	        android:maxHeight="5dip"
     	        android:thumb="@drawable/yuan"
        />

3.遇到问题

  3.1 thumb不居中显示

     添加代码:   android:maxHeight="5dip"   即可

 3.2 thumb 和seekbar有间隙,或者会有黑色边框之类

添加代码:  android:splitTrack="false"

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值