如何制作像温度计一样的搜索杆 [英] How make seekbar like thermometer

查看:108
本文介绍了如何制作像温度计一样的搜索杆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经定制了搜索杆及其工作原理,但是真正的问题是在其上绘制像温度计一样的缺口,该缺口可以动态变化,并且与搜索杆的距离相等.

I have customized the seek bar and its working fine, but the real problem is to draw the notched like thermometer on it which can be dynamic and takes the equal distance of that of the Seek Bar.

示例搜索栏最大值= 10 那么应该有10个线段,为此我们需要以相等的距离绘制11条线,以使拇指恰好位于凹口的中心.

Example Seek Bar Max = 10 then there should be 10 segments, for which we need to draw 11 lines in equal distance so that the thumb comes exactly center to the notch.

推荐答案

为简单起见,您可以使用带有RelativeLayout的搜索栏,并在后台显示温度计图像.

To keep things simple you could use a seekbar with a RelativeLayout displaying a thermometer image in background.

确保您拥有温度计图像在您的drawbles文件夹中. 只需使用 android:rotation =-90"

Make sure you have a thermometer image in you drawbles folder. Just rotate your seekbar using android:rotation="-90"

         <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/root_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <RelativeLayout
                android:layout_width="632px"
                android:layout_height="1300px"
                android:layout_below="@+id/rel"
                android:layout_gravity="center"
                android:background="@drawable/thermometer1">

            </RelativeLayout>

            <SeekBar
                android:layout_width="1052px"
                android:layout_height="50dp"
                android:layout_marginLeft="136dp"
                android:layout_marginRight="12dp"
                android:layout_marginTop="338dp"
                android:rotation="-90"
                />

        </FrameLayout>

这是结果:

这篇关于如何制作像温度计一样的搜索杆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆