如何使搜索条像温度计

时间:2013-08-29 15:26:05

标签: android

我已经定制了搜索条及其工作正常,但真正的问题是在其上绘制缺口温度计,它可以是动态的并且与Seek Bar的距离相等。

示例Seek Bar Max = 10 然后应该有10个段,我们需要在相等的距离上绘制11条线,这样拇指就会完全位于凹槽的中心位置。

enter image description here

1 个答案:

答案 0 :(得分:0)

为了简单起见,您可以使用带有RelativeLayout的搜索栏,在背景中显示温度计图像。

确保您的drawbles文件夹中有thermometer image。 只需使用 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>

结果如下:

enter image description here

相关问题