布局约束MapView类的大小 [英] Layout to constrain size of MapView

查看:320
本文介绍了布局约束MapView类的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,这样它占用约束一个图形页面的大小,说90%的屏幕的高度和树叶,其余10%在底部的另一种观点认为例如一个菜单栏。我可以得到的效果,但在菜单栏覆盖的MapView使地图的底部是不可见的。虽然图形页面可以滚动谷歌标志部分遮蔽(我怀疑这可能是对T&放大器;地图API C的),我宁愿限制的MapView被包含在屏幕的指定部分内。到目前为止,我还没有发现它执行的MapView正常布局约束例如任何布局layout_weight。

I'm trying to constrain the size of a MapView so that it takes up, say 90% of the screen's height and leaves the remaining 10% at the bottom for another view e.g. a menu bar. I can get the effect but the menu bar overlays the MapView so that the bottom part of the map is not visible. Although the MapView can scroll the Google logo is partly obscured (and I suspect this might be against the T & C's of the Maps API), I'd rather constrain the MapView to be contained within a designated part of the screen. So far I haven't found any layout which enforces the MapView to the normal layout constraints e.g. layout_weight.

我开始想通过获取设备的屏幕尺寸,这只能通过编程实现,然后明确设置的MapView布局的宽度和高度,或有任何人管理与XML布局做到这一点。

I'm beginning to think that this can only be achieved programatically by getting the device's screen dimensions and then explicitly setting the MapView layout width and height or has anyone managed to do this with an xml layout.

推荐答案

我找到了答案的此处。这基本上是什么约翰说,使用layout_weight:

I found the answer here. It is basically what John said, use layout_weight:

<LinearLayout ... >
 <FrameLayout android:id="@+id/map_frame"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_weight="0.7" >     

    <com.google.android.maps.MapView
        android:id="@+id/map_view" 
        android:layout_width="fill_parent"
        android:layout_height="match_parent" 
        android:enabled="true" 
        android:clickable="true"             
        android:apiKey="api_key"/>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />
 </FrameLayout>
</LinearLayout>

这篇关于布局约束MapView类的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆