moagrius / TileView

TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.
MIT License
1.46k stars 337 forks source link

Things not working if I add tileView not as 'setContentView(tileView)' #377

Closed ghost closed 7 years ago

ghost commented 7 years ago

In MainActivity.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:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#bbbbbb"
    tools:context="com.packagename.main_activity.MainActivity">

    <!-- Im gonna add tileView inside this container below -->
    <RelativeLayout
        android:id="@+id/tileview_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</RelativeLayout>

I created a tileView the same way the sample code did. Then at the very end, instead of

setContentView(tileView);

I did:

RelativeLayout tileViewContainer = (RelativeLayout) findViewById(R.id.tileview_container);
tileViewContainer.addView(tileView);

The tileView appears perfectly well. But now, things like

 tileView.addMarker( someView, 250, 500, -0.5f, -1.0f );

don't work..

I tried to look inside the code, but didn't get to figure out how to get it to work.

Can you give me some idea on how to solve this?

moagrius commented 7 years ago

You need layout params for any child of your RelativeLayout. Please research basic Android operations before creating a TileView issue. Thanks