Android   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 在API Maps v2的自定义信息窗口中的RelativeLayout宽度大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我有一个Google Maps API v2的自定义信息窗口,它使用通过在我的班级覆盖geTinfoWindow添加的RelativeLayout.这个布局有一个TextView,第一行有一个标题,下一行有三个TextView,一个对齐到左边,另一个对齐到中心,第三个对齐到右边.它可以工作,但窗口占据了整个屏幕,这在平板电脑等大屏幕上非常难看.

我试图将RelativeLayout的宽度设置为某个固定值(比如说“50dp”)或“wrap_content”,但它总是需要整个屏幕.

这是布局的XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://scheR_576_11845@as.android.com/apk/res/android"
    android:id="@+id/bus_stop_info_window"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:BACkground="#ffffffff" >

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:text="A title" >
    </TextView>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layouT_Below="@id/title"
        android:gravity="left"
        android:text="Test1" >
    </TextView>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layouT_Below="@id/title"
        android:gravity="center"
        android:text="Test2" >
    </TextView>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layouT_Below="@id/title"
        android:gravity="left"
        android:text="Test3" >
    </TextView>

</RelativeLayout>

我怎样才能达到预期的效果

解决方法:

为此,将根元素设置为线性布局并将相对布局放入其中.因此该窗口不会在平板电脑中填充整个屏幕.这不会影响相对布局宽度是wrap_content还是固定大小.

你可以尝试我的答案here

大佬总结

以上是大佬教程为你收集整理的android – 在API Maps v2的自定义信息窗口中的RelativeLayout宽度全部内容,希望文章能够帮你解决android – 在API Maps v2的自定义信息窗口中的RelativeLayout宽度所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: