Issue
Currently I am showing Google Map in Android phone using Java on the whole screen which is working fine for me.
public class MainActivity extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
Below is my XML file-
<?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">
<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0vAX8Xe9xjo5gkFNEEIH7KdHkNZNJWNnsjUPKkQ"
/>
</RelativeLayout>
Problem Statement:-
I need to show the Google Map on the Top Half of the Android Screen instead of showing on the full screen. And on the Bottom Half of the Screen I need to show TextBox. Is it possible to do this?
Any thoughts will be appreciated.
Solution
Yeah its possible and can easily be implemented with LinearLayout. By assigning weight to MapView and TextView.
In this case
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:apiKey="0vAX8Xe9xjo5gkFNEEIH7KdHkNZNJWNnsjUPKkQ"
android:clickable="true"
android:enabled="true" />
<TextView
android:id="@+id/textView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="TextView" />
</LinearLayout>
Answered By - Akram
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.