0
我有一個地圖,我想放置ImageView,其頂端觸及赤道。我將屬性centerVertical = true和centerHorizontal = true賦予ImageView,但它沒有定位在赤道上。我得到了地圖的中心,但我希望ImageView定位在地圖的赤道上。Android地圖ImageView在赤道上的地圖
截圖:
代碼:
@Override
public void onMapReady(GoogleMap googleMap) {
this.googleMap = googleMap;
googleMap.getUiSettings().setZoomControlsEnabled(true);
googleMap.getUiSettings().setCompassEnabled(true);
//center of map
LatLng centerOfMap=this.googleMap.getCameraPosition().target;
}
marker_view.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/marker_icon_view"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="162dp"
android:contentDescription="@string/app_name"
android:src="@drawable/marker" />
</RelativeLayout>
我想,即使用戶移動地圖 – jobin
使用投影類我赤道的經緯度(0.0,0.0)的屏幕位置可看到的標記,但它表明X y值爲0. – jobin
只需將「雙倍高度」設置爲「drawable/marker」,其中心應位於底部。並看看[this](http://stackoverflow.com/q/40112760/6950238)的對話。 –