我在试着创建一个量规。我有一个空白仪表的PNG和第二个,完全相同的大小显示针。我的想法是将指针覆盖在仪表的顶部,然后根据我希望显示的值旋转它。我很难把一张图片放在另一张图片上。有人知道怎么做吗?图像在LinearLayout中。
发布于 2018-01-29 00:14:28
为此,您可以使用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>此设置应如下所示:

我希望我能帮上忙
https://stackoverflow.com/questions/35722323
复制相似问题