【问题标题】:How make seekbar like thermometer如何制作像温度计一样的搜索栏
【发布时间】:2013-08-29 15:26:05
【问题描述】:

我已经定制了搜索栏,它的工作正常,但真正的问题是在其上画出像温度计一样的缺口,它可以是动态的,并且与搜索栏的距离相等。

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

【问题讨论】:

  • 自定义背景绘制怎么样?

标签: android


【解决方案1】:

为简单起见,您可以使用带有 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>

这是结果:

【讨论】:

    猜你喜欢
    • 2010-12-18
    • 1970-01-01
    • 1970-01-01
    • 2019-04-13
    • 1970-01-01
    • 2020-03-28
    • 2021-03-24
    • 2022-12-02
    • 2015-05-14
    相关资源
    最近更新 更多