Android 创建量规
我正在尝试创建一个测量仪。我有一个PNG的空白量表和第二个,完全相同的大小显示针。我的想法是将指针覆盖在仪表顶部,然后根据我希望显示的值旋转指针。Android 创建量规,android,Android,我正在尝试创建一个测量仪。我有一个PNG的空白量表和第二个,完全相同的大小显示针。我的想法是将指针覆盖在仪表顶部,然后根据我希望显示的值旋转指针。 我无法将一个图像置于另一个图像之上。有人知道怎么做吗?该图像位于线性布局中。您可以为此使用RelativeLayout <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"&
我无法将一个图像置于另一个图像之上。有人知道怎么做吗?该图像位于线性布局中。您可以为此使用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个月前完成的一个项目,使用了我在别处找到的一个定制仪表。事实上,我正计划很快重写它,所以我将尝试你的解决方案。