Here's the setup:
I'm constructing and displaying Activities that are styled as centered Dialogs. This is to show hierarchical content that shouldn't be full-screen on the device.
One type of content is a map. So i've successfully loaded a MapFragment into a Dialog-styled FragmentActivity. This works really well.
The problem is when I attempt to place a new TextView (acting as a custom title bar) above the map. The issue is that the TextView's content seems to become transparent and the previous Activity's content bleeds through.
The exact same "design" works just fine when the map's activity allows the map to be full screen. The problem is only when i try to make the map a custom size (and also be displayed along with another view).
Here's the Activity:
public class MapViewActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_map_view);
Window window = this.getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
WindowManager.LayoutParams wmlp = window.getAttributes();
wmlp.y -= 10;
window.setAttributes(wmlp);
Intent i = getIntent();
String lat = i.getExtras().getString("lat");
String lng = i.getExtras().getString("lng");
String title = i.getExtras().getString("title");
String snippet = i.getExtras().getString("address");
TextView tv = (TextView)this.findViewById(R.id.mapTitle);
tv.setText(title);
SupportMapFragment mf = (SupportMapFragment)this.getSupportFragmentManager().findFragmentById(R.id.map);
MarkerOptions mo = new MarkerOptions();
mo.position(new LatLng( Double.valueOf(lat), Double.valueOf(lng) ));
mo.title(title);
mo.snippet(snippet);
GoogleMap gm = mf.getMap();
gm.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng( Double.valueOf(lat), Double.valueOf(lng) ), 14));
gm.setMapType(GoogleMap.MAP_TYPE_NORMAL);
gm.setMyLocationEnabled(true);
gm.addMarker(mo);
}
}
Here's the layout xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="300dp"
android:layout_height="365dp"
tools:context=".MapViewActivity" >
<TextView
android:id="@+id/mapTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:textSize="18sp"
android:textColor="@color/white"
android:background="@color/blue"
android:text="TEST TITLE LABEL"
>
</TextView>
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="280dp"
android:layout_below="@id/mapTitle"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
Here's the style that I use when defining the Activity in the manifest:
<style name="SubViewTheme" parent="android:Theme.Dialog">
<item name="android:windowAnimationStyle">@style/MainViewAnimation</item>
<item name="android:windowBackground">@color/white</item>
<item name="android:background">@null</item>
</style>
All i'm doing to show the activity is using a standard start startActivity(i);
And here's a screen cap of the outcome. Sorry for the poor quality. It's a pain to get a screen cap of my Nexus1.
"screen shot of the map dialog"
In the screen shot you'll see the "dialog" activity with the map. And the TextView IS appearing - the TextView is the small dark-blue rectangle at the top right of the map. then to the left of the messed up label we have the text from the previous dialog bleeding through where the TextView SHOULD be.
Is there anything obvious that I'm doing wrong? Maybe i'm being too ambitious with the new MapFragment support :).
This project requires support back to 2.3.3 so i'm stuck with the support libs.
Thanks for any help. Let me know if anything in my description doesn't make sense.