这里实现了如下所示的进度条
进度条如线状显示,带有少许发散效果
拖拽按钮用圆显示,采用发散效果。(类似太阳的效果)
这个效果主要有这样几个难点:进度条的高度会随着seekbar的宽度变化,然而seekbar宽度过小又会遮罩住部分拖拽按钮;拖拽按钮使用shape方式生产,而非图像。网上给的这部分介绍基本采用了一个版本,具体介绍见http://bashenmail.iteye.com/blog/603649 ,该文给出的实现方法并没有解决了这两个难点。~~~~(>_<)~~~~ ,折腾来折腾去的...
转载请注明http://ishelf.iteye.com/admin/blogs/741470
接下来边贴代码边介绍。这里是基于android源码给出的实例修改而成的(只给出了部分重要代码),首先给出主界面
Java代码 复制代码 收藏代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"><!--
<SeekBar android:id="@+id/seek1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="50"
android:secondaryProgress="75" />
--><SeekBar android:id="@+id/seek"
android:layout_width="fill_parent" android:progressDrawable="@drawable/seekbar_style"
android:thumb="@drawable/thumb1" android:layout_height="wrap_content"
android:paddingLeft="2px" android:paddingRight="3dip"
android:paddingBottom="4px" />
<TextView android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView android:id="@+id/tracking"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
[java] view plaincopy
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"><!--
<SeekBar android:id="@+id/seek1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="50"
android:secondaryProgress="75" />
--><SeekBar android:id="@+id/seek"
android:layout_width="fill_parent" android:progressDrawable="@drawable/seekbar_style"
android:thumb="@drawable/thumb1" android:layout_height="wrap_content"
android:paddingLeft="2px" android:paddingRight="3dip"
android:paddingBottom="4px" />
<TextView android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView android:id="@+id/tracking"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
注意一下两个属性
Java代码 复制代码 收藏代码
android:progressDrawable="@drawable/seekbar_style"//进度条
android:thumb="@drawable/thumb1"//拖拽按钮
[java] view plaincopy
android:progressDrawable="@drawable/seekbar_style"//进度条
android:thumb="@drawable/thumb1"//拖拽按钮
它们对应的xml档案如下:
thumb1.xml
Xml代码 复制代码 收藏代码
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 按下状态-->
<item android:state_focused="true" android:state_pressed="true">
<shape android:shape="oval">
<gradient android:type="radial" android:gradientRadius="8"
android:angle="0" android:startColor="#FFFF0000"
android:centerColor="#FF00FF00" android:endColor="#000000" />
<size android:width="16dip" android:height="16dip"></size>
</shape>
</item>
......//这里用的oval椭圆,注意gradient android:type=
......//"radial" android:gradientRadius="8" 这两个属性需
......//要一起使用。
......
</selector>
[xml] view plaincopy
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 按下状态-->
<item android:state_focused="true" android:state_pressed="true">
<shape android:shape="oval">
<gradient android:type="radial" android:gradientRadius="8"
android:angle="0" android:startColor="#FFFF0000"
android:centerColor="#FF00FF00" android:endColor="#000000" />
<size android:width="16dip" android:height="16dip"></size>
</shape>
</item>
......//这里用的oval椭圆,注意gradient android:type=
......//"radial" android:gradientRadius="8" 这两个属性需
......//要一起使用。
......
</selector>
seekbar_style.xml
Xml代码 复制代码 收藏代码
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
................//
................//
................//
<item android:id="@android:id/progress">
<clip>
<shape android:shape="rectangle">
<corners android:radius="2dip" />
<gradient android:startColor="#80000000" android:width="5dp"
android:centerColor="#7e209e" android:centerY="0.5" android:angle="90"
android:endColor="#80000000" />
<stroke android:width="8dp" android:color="#80000000"
android:dashWidth="3dp" android:dashGap="2dp" />
</shape>
</clip>
............//在这里设置高度实验了很多次总是行不通(谁要是通过
............//这种方法搞定高度,记得留言给我(~ o ~)~)
............//于是使用了一个遮罩层(边框),因为边框的高度也
............//是由seekbar决定的。这里将进度条的大部分遮
............//罩,只留出中间一部分。还有注意这里的边框
............//使用的间隔效果,所以会有发散的效果。具体效果怎样
............//需要自己测试一下,这里就不贴图了。
</layer-list>
分享到:
相关推荐
当滑动时:数值显示,滑动停止时显示数字,使用FrameLayout结合SeekBar。 首先我们看看。 Layout: <?xml version=1.0 encoding=utf-8?> xmlns:tools=http://schemas.android.com/tools> <...
一个横竖向都可以的SeekBar 控件
Android自定义垂直seekbar,可成功监听seekbar的各个状态,是很好的代码
seekbar和竖向seekbar
自定义的圆弧行SeekBar。(PS:不支持0%-100%跳转)
android实例竖着的seekbar
Android自定义SeekBar滑动条
Android双向seekbar(带刻度),自定义view,控制上限和下限
仿QQ设置字体大小、带刻度的SeekBar。 思路:自定义view其实就像一个画画过程,步骤如下: a:首先画刻度条; b:刻度描述; c:然后画拖动块; d:响应手势。
SeekBar
seekbar设置进度条的颜色 博客地址: http://mp.blog.csdn.net/mdeditor/index/79272809
SeekBar 实现网络获取图片随thumb滑动,,并位于中间位置,图片采用glide加载方式,图片位于seekbar居中;
本源码主要是学习SeekBar、ProgressBar用法,拖动条与进度条结合,当拖动拖动条的时候,ProgressBar跟随着变化,普通拖拉条被拉动的处理代码: SeekBar sb=(SeekBar)this.findViewById(R.id.SeekBar01); sb....
横向SeekBar 样式设置,自定义竖向SeekBar.
android自定义seekbar刻度条控制网页字体大小
安卓 android seekbar 自定义滑块 适合做音量调节 比较漂亮 我的资源汇总:http://blog.csdn.net/u013506037/article/details/39210793
android 自定义Seekbar,包括图片,背景颜色,网上的小例子
seekbar 动态移动带百分比TextView 详细源码
Essentially it’s a SeekBar that has been wrapped around a circle. It acts like a SeekBar and generally has the same settings. You can even add a Listener to it as you would with a SeekBar. So if its...
android_SeekBar竖直显示自定义背景thumb完美Demo(附带解决说明)