【问题标题】:Google maps inside Viewpager is bigger than screenViewpager 内的谷歌地图比屏幕还大
【发布时间】:2019-05-24 03:35:51
【问题描述】:

我有一个简单的选项卡布局(用于生成基础知识),其中一个选项卡上显示了谷歌地图。问题是 viewpager 似乎比可用空间大。结果是我的地图缩放按钮是屏幕的一半。

我尝试了各种更改布局 XML 的顺序并搜索互联网,但到目前为止没有任何效果

我的布局文件

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".MemoryContainerActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/appbar_padding_top"
        android:theme="@style/Default.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:layout_weight="1"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/Default.PopupOverlay"
            app:title="@string/title_activity_view_memory">

        </android.support.v7.widget.Toolbar>

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.design.widget.TabItem
                android:id="@+id/tabItem1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/tab_text_1"/>

            <android.support.design.widget.TabItem
                android:id="@+id/tabItem2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/tab_text_2"/>

            <android.support.design.widget.TabItem
                android:id="@+id/tabItem3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/tab_text_3"/>

        </android.support.design.widget.TabLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</android.support.design.widget.CoordinatorLayout>

在 tab1 和 tab2 上,当我滚动工具栏时,它会很好地向上移动。但是在标签 3 上,我有一个带有谷歌地图的片段。尺寸属性是匹配父级的。所以滚动只会在地图中移动我(就像我应该的那样),但不会移动工具栏。

结果是这样的: Sreen capture of result

【问题讨论】:

    标签: android google-maps android-viewpager


    【解决方案1】:

    由于缺乏更好的解决方案,我通过将上述 XML 拆分为活动 XML 和内容 XML 来解决它。 现在可以了,但是为什么???我不知道。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      • 2011-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-07
      相关资源
      最近更新 更多