android - ViewPager 中的部 fragment 段在屏幕底部被截断(Android)

标签 android android-layout android-fragments material-design android-support-library

我已经为我的 View 定义了一个基本的 Coordinator 布局:

<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.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabIndicatorColor="@color/white"
            app:tabMode="fixed"/>
    </android.support.design.widget.AppBarLayout>

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

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

我的 View 寻呼机中有多个标签。我正在发布我的一个简单 fragment :

<ListView
    android:id="@+id/transferList"
    android:layout_width="match_parent"
    android:layout_height="match_parent"></ListView>

<android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="@dimen/activity_vertical_margin"
    android:layout_marginRight="@dimen/activity_horizontal_margin"
    android:layout_alignParentRight="true"
    android:src="@drawable/ic_add_white" />

FAB 出现在屏幕外。这不是 FAB,而是其他带有卡片 View / ListView 的 fragment 在屏幕底部被截断。我环顾四周寻找解决方案,并想出了一个 hacky 解决方案:从工具栏中删除属性 app:layout_scrollFlags="scroll|enterAlways"

我无法理解导致这种情况发生的原因,以及删除上述内容如何解决问题。它是支持库中的一些错误吗?有没有更好的方法来解决这个问题?我遇到的另一个解决方案来自 here - 将 FAB 按钮直接保留在 Activity 中的 Coordinator 布局下,并使其仅在您需要的 fragment 中可见。对我来说似乎不是一个好的解决方案。另外,我的 fragment 中的其他 View 也被截断了。

最佳答案

我已通过将 Toolbarapp:layout_scrollFlags="scroll|enterAlways" 属性更改为 app:layout_scrollFlags="enterAlways"解决了这个问题.

关于android - ViewPager 中的部 fragment 段在屏幕底部被截断(Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34407024/

相关文章:

android - Sonar Jacoco for Kotlin Setup 不生成代码覆盖率

android - fragment YouTubePlayerSupportFragment 中的重复 ID

android - 在 Appium 中,通过不是 View id 字段的唯一 id 查找 Android View

android - 如何获取 fragment 方法内已实现回调的上下文

Android 剪辑 canvas.drawBitmap

android - 在 gridview 项目之间显示一条细线

android - 从 EditText 设置日期选择器对话框的日期

android - 标签栏和抽屉导航对齐

android - 非法状态异常 : RecyclerView is null inside of Fragment within NavigationDrawer activity

java - 使用 Android Google Maps API 设置 MapType 空指针异常