Issue
I'm trying to use a mapview object in my app, but I need to simultaneously display additional information. I'd like to have have some textviews under the map, but I can't seem to display the mapview without it expanding to the entire screen. I've tried both linearlayout and relativelayout.
I'm attaching an image that shows how the bottom TextView is draw on top of the "google" logo, and hides part of it. I want (should?) have this displayed (give credit where credit is due). MY only alternative that I can figure out is to put all my text at the top of the map, which I have reasons for not wanting to do.
Any help and/or tricks would be greatly appreciated.
Thanks,
Sid
Here is my code
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.app.Activity;
import android.os.Bundle;
public class maptest extends MapActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(com.isti.sms.R.layout.mapviewtest);
MapView mv = (MapView)this.findViewById(com.isti.sms.R.id.mapview);
mv.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
And the xml is
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:orientation="vertical" >
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/linearLayout1"
android:layout_below="@+id/LabelArea"
android:apiKey="my long key"
android:clickable="true" />
</LinearLayout>
<LinearLayout
android:id="@+id/LabelArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#FFFFFF"
android:orientation="vertical" >
<TextView
android:id="@+id/eventinfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:padding="5dip"
android:text="TextView"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#0000FF" >
</TextView>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<TextView
android:id="@+id/hrlegendtx"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#FFFFFF"
android:text="1 Hr"
android:textColor="#0000FF" />
</LinearLayout>
</RelativeLayout>
Solution
You can use LinearLayout and layout_weight property:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:apiKey="my long key"
android:layout_weight="1"
android:clickable="true" />
<TextView
android:id="@+id/hrlegendtx"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="#FFFFFF"
android:text="1 Hr"
android:textColor="#0000FF" />
</LinearLayout>
Answered By - Gregory Kalabin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.