Ich habe ein Bild der Karte (feste Größe), um als Hintergrund angezeigt werden, und ich möchte ein Player-Symbol darüber anzeigen. Ich erhalte die aktuellen Koordinaten des Spielers als android.graphic.Point.Android: Anzeigen von Player-Symbol auf der Karte basierend auf Coords
Ich versuchte RelativeLayout mit der Einrichtung von Margen, die irgendwie funktionierte, aber wenn die Anzeige gedreht wird, ist das Symbol offensichtlich anderswo verschoben. Auch ich denke diese absolute Positionierung kann nicht auf unterschiedlicher Bildschirmgröße arbeiten ...
Irgendwelche Vorschläge, wie man das so beabsichtigt?
Das ist mein XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:id="@+id/mapLayout"
tools:context="cz.alois_seckar.vseadventrura.MapActivity">
<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@+id/playerIcon"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/player" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/mapImage"
android:src="@drawable/spacemap"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/back_button"
android:id="@+id/mapBackButton"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:onClick="goBack"/>
</RelativeLayout>
Und das ist, wie ich bin (Wieder-) Player-Symbol platzieren
RelativeLayout mapLayout = (RelativeLayout) findViewById(R.id.mapLayout);
mapLayout.removeView(playerIcon);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(40, 40);
Point playerCoords = game.getWorld().getCurrentSpace().getPosition();
params.leftMargin = playerCoords.x;
params.topMargin = playerCoords.y;
mapLayout.addView(playerIcon, params);