Android seekbar with custom thumb

一曲冷凌霜 提交于 2019-12-07 16:28:56

问题


I want to create a seekbar like in this image:

seekbar http://i47.tinypic.com/k2k54z.jpg

The question is, how to place thumb above the progress line?

This line

android:thumb="@drawable/thumb"

places the thumb in the center of the line. Any suggestions?


回答1:


you can assume the whole bar and the above thumb as one seekbar what you have to do is just include the blank area above the bar in progress and background image and include the blank area below the thumb in the image for thumb.




回答2:


I am also face same problem..and find out the following solution,

Solution - Adjust your thumb with layer-list..

Create custom_thumb.xml (in your drawable folder)

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="50dp"
android:height="50dp"
android:top="35dp"
android:bottom="35dp"
android:drawable="@drawable/thumb"/>

</layer-list>

Adjust width, height,top,bottom as per your need.

and set thumb using following code

android:thumb="@drawable/custom_thumb"


来源:https://stackoverflow.com/questions/12099321/android-seekbar-with-custom-thumb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!