ViewPager#39;s height in Coordinator layout is more than available(ViewPager 在 Coordinator 布局中的高度超过可用)
问题描述
我有一个 CoordinatorLayout,在 AppBarLayout 内有一个 Toolbar 和一个 TabLayout.此外,我在 CoordinatorLayout 内但在 ViewPager 之外有一个 ViewPager.
问题是 ViewPager 的 高度大于实际可用的高度,导致我的 Fragment 中的一些视图被剪切.
<?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"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@color/lightGray"android:fitsSystemWindows="true"> 解决方案 可能的 hack 可以是添加 与工具栏相同的底部边距,即
?attr/actionBarSize .您甚至可以摆弄其他可能的 ui hacks 边距,以获得最佳结果.
I have a CoordinatorLayout with a Toolbar and a TabLayout inside the AppBarLayout. Additionally, I have a ViewPager inside the CoordinatorLayout but outside the ViewPager.
The problem is that the ViewPager's height is bigger than what is actually available, resulting in some views from my Fragment being cut.
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lightGray"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:scrollbars="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="false"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
And this what I mean when I say that the ViewPager has the wrong height.
解决方案 A possible hack can be adding same bottom margin as toolbar which is
?attr/actionBarSize . You can even fiddle around with other possible ui hacks of margins to give you best result.
这篇关于ViewPager 在 Coordinator 布局中的高度超过可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ViewPager 在 Coordinator 布局中的高度超过可用
基础教程推荐
- 如何从 logcat 中删除旧数据? 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
