相关疑难解决方法(0)

ViewPager里面的部分片段在屏幕底部被截断(Android)

我为我的视图定义了一个基本的协调器布局:

<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>
Run Code Online (Sandbox Code Playgroud)

我的视图寻呼机中有多个选项卡.我发布了一个简单的片段:

<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" />
Run Code Online (Sandbox Code Playgroud)

会发生什么是FAB离开屏幕.这不是FAB,但其他具有cardviews/listview的片段在屏幕底部被截断.我四处寻找解决方案,并提出了一个hacky解决方案:从工具栏中删除属性app:layout_scrollFlags ="scroll | enterAlways".

我无法理解可能导致这种情况发生的原因,以及如何解决上述问题解决了问题.它是支持库中的一些错误吗?有没有更好的方法来解决这个问题?我遇到的另一个解决方案是从这里开始 - 将FAB按钮直接保持在活动中的Coordinator布局下,并使其仅在您需要的片段中可见.对我来说似乎不是一个好的解决方案.此外,我的片段中的其他观点也被切断了.

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

23
推荐指数
2
解决办法
5871
查看次数

布局位于StatusBar和Soft Keys下

我不知道我是怎么做到这一点的,我找不到类似的东西,但我的软件导航和状态栏正在我的布局上绘制,而不是我的布局适合它们.

如何让我的布局在它们之间绘制而不是在?

例

编辑:

这似乎是罪魁祸首,位于风格:

    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
Run Code Online (Sandbox Code Playgroud)

android translucency navigationbar android-layout android-statusbar

4
推荐指数
1
解决办法
2520
查看次数