我有一个简单的制表符布局(用于生成基本信息的库),其中一个选项卡上显示了google maps。问题在于,viewpager似乎比可用空间大。结果是我的地图缩放按钮在屏幕的一半。
我尝试过各种方法来更改布局XML的顺序并搜索Internet,但到目前为止没有任何效果
我的布局文件
<?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上,我有一个片段,上面有Google地图。大小属性是匹配父项。因此,滚动只会使我在地图上移动(就像我应该那样),但不会移动工具栏。
结果是这样的: Sreen capture of result
答案 0 :(得分:0)
由于缺乏更好的解决方案,我通过将上述XML分为activity-XML和content-XML来解决了它。 现在可以了,但是为什么呢?我不知道。