首页 技术 正文
技术 2022年11月20日
0 收藏 698 点赞 4,395 浏览 1881 个字

Android 自定义seekbar中,thumb被覆盖掉一部分问题 (图一)  Android 自定义seekbar中,thumb被覆盖掉一部分问题 (图二)    Android 自定义seekbar中,thumb被覆盖掉一部分问题 (图三)

做一个自定义的seekbar,更改其背景图片:

<com.android.Progress
android:id="@+id/focus_seekbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/seekbar_add"
android:progressDrawable="@drawable/seekbar_img"
android:thumb="@drawable/thumb"
android:max = ""/>

定义progressDrawable即为背景图片。thumb为滑块图片

如上定义xml文件,启动程序,生成如图一。 thumb滑块不能显示完全,一部分被隐藏掉。

增加属性:

android:thumbOffset="0dip"

即可实现thumb不被覆盖,即最下方位置如图三所示,不会出现图一情况。

网上有个竖直的VerticalSeekBar,简单说一下他的使用:

当滑块的大小比下面的背景大时,此时要设置

android:minHeight=”19dip”
                android:maxHeight=”19dip”

19dip即为seek_img图片的宽度。

而控件的layout_width值即位滑块的width和height值

<com.android.VerticalSeek
android:id="@+id/focus_seekbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:progressDrawable="@drawable/seekbar_img"
android:thumb="@drawable/thumb"
android:thumbOffset="0dip"
android:max = ""
android:layout_centerVertical="true"
android:minHeight="19dip"
android:maxHeight="19dip"
android:paddingLeft="-15dip"
android:paddingRight="-15dip"/>

Android 自定义seekbar中,thumb被覆盖掉一部分问题

这么个小问题,用了我半天时间才搞出来。网上资源太少了,给大家分享一下。

<?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="5dip" />
<gradient
android:startColor="#ff364956"
android:centerColor="#ff444444"
android:centerY="0.75"
android:endColor="#ff00112e"
android:angle=""
/>
</shape>
</item> <item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#80364956"
android:centerColor="#802f67a6"
android:centerY="0.75"
android:endColor="#8000112e"
android:angle=""
/>
</shape>
</clip>
</item> <item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#ff9ee5ff"
android:centerColor="#ff9ee5ff"
android:centerY="0.75"
android:endColor="#ff9ee5ff"
android:angle=""
/>
</shape>
</clip>
</item></layer-list>
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,028
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,518
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,365
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,146
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,780
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,857