SeekBar配置文件:java

android:id="@+id/player_seekbar"

android:layout_width="245px"

android:layout_height="25px"

android:progressDrawable="@drawable/seekbar_style"

android:thumb="@drawable/thumb"

android:paddingLeft="16px"

android:paddingRight="15px"

android:paddingTop="5px"

android:paddingBottom="5px"

android:progress="0"

android:max="0"

android:secondaryProgress="0"

/>

android:id="@+id/player_seekbar"

android:layout_width="245px"

android:layout_height="25px"

android:progressDrawable="@drawable/seekbar_style"

android:thumb="@drawable/thumb"

android:paddingLeft="16px"

android:paddingRight="15px"

android:paddingTop="5px"

android:paddingBottom="5px"

android:progress="0"

android:max="0"

android:secondaryProgress="0"

/>

android:progressDrawable="@drawable/seekbar_style"背景条android

seekbar_style配置以下:spa

android:startColor="#ff9d9e9d"

android:centerColor="#ff5a5d5a"

android:centerY="0.75"

android:endColor="#ff747674"

android:angle="270"

/>

android:startColor="#80ffd300"

android:centerColor="#80ffb600"

android:centerY="0.75"

android:endColor="#a0ffcb00"

android:angle="270"

/>

android:startColor="#ff0099CC"

android:centerColor="#ff3399CC"

android:centerY="0.75"

android:endColor="#ff6699CC"

android:angle="270"

/>

android:startColor="#ff9d9e9d"

android:centerColor="#ff5a5d5a"

android:centerY="0.75"

android:endColor="#ff747674"

android:angle="270"

/>

android:startColor="#80ffd300"

android:centerColor="#80ffb600"

android:centerY="0.75"

android:endColor="#a0ffcb00"

android:angle="270"

/>

android:startColor="#ff0099CC"

android:centerColor="#ff3399CC"

android:centerY="0.75"

android:endColor="#ff6699CC"

android:angle="270"

/>

或者:用图片以下:

android:drawable="@drawable/progress_bg" />

android:drawable="@drawable/second_progress">

android:drawable="@drawable/first_progress">

方形

android:drawable="@drawable/progress_bg" />

android:thumb="@drawable/thumb"就是那个会动的球code

配置以下:orm

android:state_focused="true"

android:state_pressed="true"

android:drawable="@drawable/thumb_pressed" />

android:state_focused="false"

android:state_pressed="false"

android:drawable="@drawable/thumb_normal" />

android:state_focused="true"

android:state_pressed="false"

android:drawable="@drawable/thumb_focused" />

android:state_focused="true"

android:drawable="@drawable/thumb_focused" />

使用9patch图时的用法:xml

我作项目中遇到的问题时,无论时设置drawable,仍是9patch图片,或者时shape,seekbar拖动时老是不现实背景,很郁闷,后来发现是由于进度条和第二进度条在xml文件中设置时没有clip的缘故。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐