Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 创建量规_Android - Fatal编程技术网

Android 创建量规

Android 创建量规,android,Android,我正在尝试创建一个测量仪。我有一个PNG的空白量表和第二个,完全相同的大小显示针。我的想法是将指针覆盖在仪表顶部,然后根据我希望显示的值旋转指针。 我无法将一个图像置于另一个图像之上。有人知道怎么做吗?该图像位于线性布局中。您可以为此使用RelativeLayout <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"&

我正在尝试创建一个测量仪。我有一个PNG的空白量表和第二个,完全相同的大小显示针。我的想法是将指针覆盖在仪表顶部,然后根据我希望显示的值旋转指针。
我无法将一个图像置于另一个图像之上。有人知道怎么做吗?该图像位于线性布局中。

您可以为此使用RelativeLayout

<RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/needle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/needle" />

            <ImageView
                android:id="@+id/cluster"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/cluster" />

            <TextView
                android:id="@+id/rpmVal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="27dp"
                android:text="00000"
                android:textColor="#ffffff"
                android:textSize="60sp"
                android:textStyle="italic" />

            <TextView
                android:id="@+id/textView23"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/rpmVal"
                android:layout_alignBottom="@+id/rpmVal"
                android:layout_toEndOf="@+id/rpmVal"
                android:text="RPM"
                android:textColor="#ffffff" />

            <TextView
                android:id="@+id/textView24"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/rpmVal"
                android:layout_marginBottom="40dp"
                android:layout_toStartOf="@+id/textView23"
                android:text="x100 rpm"
                android:textColor="#ffffff"
                android:textSize="10sp" />

        </RelativeLayout>

此设置应如下所示:


我希望我能帮助^^

选项1:扩展图像视图并开发您自己的控制选项2:使用仪表图像作为图像视图的背景,并将指针作为src。。。备选案文3。。。。采取框架布局或相对布局。。。将两个图像放在视图1中。仪表和2。这会有帮助的:谢谢。这是我大约18个月前完成的一个项目,使用了我在别处找到的一个定制仪表。事实上,我正计划很快重写它,所以我将尝试你的解决方案。