2015-08-14 5 views
1

Я работаю с API Google Maps для Android. Карта находится внутри фрагмента. Я хочу разместить изображение внутри этого фрагмента и над картой. Моя цель - переместить фото и изменить размер событий с помощью жестов Android. Мой вопрос: Как я могу поместить изображение по карте?Поместите объект внутри фрагмента карты google

У меня есть метод, который возвращает мне изображение с изображением и позволяет мне перемещаться и изменять размер.

Как я могу поместить этот вид внутри карты?

<fragment xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/map" 

android:name="com.google.android.gms.maps.SupportMapFragment" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 

<ImageView 
    android:id="@+id/fotoPrueba" 
    android:layout_width="200dp" 
    android:layout_height="200dp" 
    android:layout_gravity="center_horizontal" 
    /> 

    </LinearLayout> 
    </fragment> 

    protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.ImageTest); 
    View view = new SandboxView(this, bitmap); //returns me a View with the image and lets me move and resize. 

    ImageView iv= (ImageView)findViewById(R.id.fotoPrueba); 
    iv.setImageBitmap(bitmap); 

    //setContentView(view); // This works but deletes my map. 

    setContentView(R.layout.activity_main); 

    map= ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); 
    } 
+0

Не размещайте такой уродливый код без отступов. Вы можете просто переформатировать его в Android Studio –

ответ

0

Положите ваши взгляды вне фрагмента карты в макете.

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

    <fragment 
     android:id="@+id/map" 
     android:name="com.google.android.gms.maps.SupportMapFragment" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 

    <ImageView 
     android:id="@+id/fotoPrueba" 
     android:layout_width="200dp" 
     android:layout_height="200dp" 
     android:layout_gravity="center_horizontal"/> 

    <!-- here can be you view --> 
    <FrameLayout 
     android:id="@+id/container" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
</FrameLayout> 
Смежные вопросы