secondaryProgress无显示效果

原文地址: http://www.eoeandroid.com/blog-600773-5417.html


碰到的问题有secondaryProgress无显示效果、seekBar高被挤压变形、Thumb有偏移,显示效果不理想等...

解决方法在下面的代码里有注释

新建android:progressDrawable的style文件:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >


    <!-- 背景图,不可加clip属性,否则无显示效果 -->
    <item android:id="@android:id/background">
        <inset
            android:insetBottom="5dip"
            android:insetTop="5dip" >
            <shape>
                <solid android:color="#40ffffff" />
            </shape>
        </inset>
    </item>

    <!-- 第二进度条,增加inset属性可以避免thumb上下被挤压遮住,三处都要写 -->
    <item android:id="@android:id/secondaryProgress">
        <clip>
            <inset
                android:insetBottom="5dip"
                android:insetTop="5dip" >
                <shape>
                    <solid android:color="#7affffff" />
                </shape>
            </inset>
        </clip>
    </item>

    <!-- 第一进度条,必须放在第二进度条的下面,否则会被第二进度条覆盖掉而看不到效果 -->
    <item android:id="@android:id/progress">
        <clip>
            <inset
                android:insetBottom="5dip"
                android:insetTop="5dip" >
                <shape>
                    <solid android:color="#ff4094eb" />
                </shape>
            </inset>
        </clip>
    </item>

</layer-list>

使用:

<!-- thumb引用的是两张图片,分别是自然和按下状态的,加上thumbOffset就是往SeekBar起点左移的距离,可以调整未与起点对齐的情况,加上pading可以避免thumb两边被遮住的情况 -->
<SeekBar
            android:id="@+id/seekBar"
            android:layout_width="wrap_content"
            android:layout_height="19dip"
            android:layout_centerVertical="true"
            android:layout_toLeftOf="@+id/totalTime"
            android:layout_toRightOf="@+id/currentTime"
            android:paddingLeft="5dip"
            android:paddingRight="5dip"
            android:progressDrawable="@drawable/video_seekbar_style"
            android:thumb="@drawable/video_seekbar_thumb_style"
            android:thumbOffset="4dip" />

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值