Android,如何使谷歌地图视图仅存在于屏幕的一部分
我正在尝试在我的应用程序中使用地图视图对象,但我需要同时显示其他信息。我希望在地图下有一些文本视图,但如果不扩展到整个屏幕,我似乎无法显示地图视图。我尝试过线性布局和相对布局。
我附上一张图像,显示底部 TextView 如何绘制在“google”徽标顶部,并隐藏其中的一部分。我希望(应该?)显示此内容(在应得的信用处给予信用)。我能想到的唯一选择是将所有文本放在地图的顶部,但我有理由不想这样做。
任何帮助和/或技巧将不胜感激。
谢谢,
Sid
这是我的代码
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;
}
}
,xml 是
<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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 LinearLayout 和 layout_weight 属性:
You can use LinearLayout and layout_weight property: