【问题标题】:Content hides under appbar layout内容隐藏在 appbar 布局下
【发布时间】:2016-07-18 14:31:39
【问题描述】:

在我的应用程序中,contet 隐藏在 appbarlayout 下。我没想到会有这种行为!

Android 23 预览版

ANDROID 21 - 在设备上测试

ANDROID 21 - 测试隐藏在工具栏下的 DEVICE 内容

尽管我的内容按预期向下滚动,但当它向上滚动时,内容隐藏在工具栏下。我还上传了 android 23 预览,因为可以看到实际上工具栏在状态栏后面对齐顶部。如果预览正确,则处理设备内容会上升到应该移动的位置。但工具栏视图位于状态栏下方而不是后面。我不知道问题出在哪里。

风格

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@color/colorPrimaryDark</item>
</style>

<style name="AppTheme.NoStatusBar" parent="AppTheme.NoActionBar">
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
    <item name="windowActionBarOverlay">true</item>
    <item name="android:windowActionBarOverlay">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>

更新

好的,我找到了解决方案。太垃圾了。只是我的 scrollView 向下滚动,因为它的最后一个孩子正在获得焦点 - 回收器视图。 不,我在 cardView focusableInTouchMode="true" 和最后一个元素上设置了 false

<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:fitsSystemWindows="true"
        android:fillViewport="true">

 <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardCornerRadius="4dp"
        android:layout_margin="4dp"
        app:contentPaddingTop="24dp"
        android:focusableInTouchMode="true"/>

...
 <android.support.v7.widget.RecyclerView
       android:id="@+id/recycler_view_overbid_history"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:maxHeight="200dp"
       android:focusable="false"
       android:focusableInTouchMode="false"/>

android.support.v4.widget.NestedScrollView>

【问题讨论】:

    标签: android android-appbarlayout android-collapsingtoolbarlayout


    【解决方案1】:

    我正在与你分享我的部分代码,它在我的应用程序中为我工作:

    <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:fitsSystemWindows="true">
    
    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="240dp"
        android:fitsSystemWindows="true">
    
        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:expandedTitleMarginBottom="140dp">
    
            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.75">
    
                <ImageView
                    android:id="@+id/store_detail_background"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="centerCrop" />
    
                ...
    
            </FrameLayout>
    
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin" />
    
        </android.support.design.widget.CollapsingToolbarLayout>
    
    </android.support.design.widget.AppBarLayout>
    
    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
    
        <FrameLayout
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    
    </android.support.v4.widget.NestedScrollView>
    

    v21/styles.xml:

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@color/...</item>
        <item name="windowActionModeOverlay">true</item>
        ...
    </style>
    

    【讨论】:

      猜你喜欢
      • 2023-03-16
      • 2020-08-26
      • 1970-01-01
      • 2015-11-29
      • 1970-01-01
      • 2016-05-12
      • 1970-01-01
      • 2012-04-12
      • 2019-01-27
      相关资源
      最近更新 更多