【问题标题】:Default height of status bar is not showing properly after upgrade library to android 23.2.1将库升级到 android 23.2.1 后,状态栏的默认高度未正确显示
【发布时间】:2016-03-29 23:25:21
【问题描述】:

我正在开发一个应用程序,需要应用底页对话框,因此我将 android.supppcom.android.support:design:23.1.1 更新为 com.android.support:设计:23.2.1。一切正常,但问题出在这里。

  1. 状态栏的默认高度比正常宽(比如如果默认是 10dp 现在高度是 30dp)。
  2. 在 Android studio 的预览中可以预览。

我不知道它是如何工作的,所以任何人都可以帮助我解决这个问题。请查找 gradle 信息。 谢谢

   dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.inkapplications.viewpageindicator:library:2.4.3'
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'commons-codec:commons-codec:1.9'
// compile 'com.android.support:multidex:1.0.0'
    compile 'com.codesnippets4all:quick-json:1.0.4'
   //    compile 'javax.persistence:persistence-api:1.0'
  //    compile 'com.android.support:design:23.1.1'
      compile 'com.android.support:design:23.2.1'
  //    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.2.1'
   //    compile 'com.android.support:recyclerview-v7:23.1.1'
   compile 'com.android.support:recyclerview-v7:23.2.1'
   //    compile 'com.android.support:appcompat-v7:23.1.1'
   compile 'com.android.support:appcompat-v7:23.2.1'
   //    compile 'com.android.support:support-v4:23.1.1'
   compile 'com.android.support:support-v4:23.2.1'

    }

    <?xml version="1.0" encoding="utf-8"?>
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
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/AppTheme.AppBarOverlay">
     <android.support.v7.widget.Toolbar
        android:id="@+id/toolbarAppHome"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />
      </android.support.design.widget.AppBarLayout>
     <FrameLayout
    android:id="@+id/frag_placeholder"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">
    </FrameLayout>
    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:background="@color/colorPrimaryDark"
    android:orientation="horizontal">

    <LinearLayout
        android:id="@+id/tab_home"
        android:orientation="vertical"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:gravity="center_vertical|center_horizontal"
        android:layout_height="match_parent">
        <ImageView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_home_white_24dp"/>
        <TextView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lable"/>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/tab_tournament"
        android:orientation="vertical"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:gravity="center_vertical|center_horizontal"
        android:layout_height="match_parent">
        <ImageView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_group_white_24dp"/>
        <TextView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lable"/>

    </LinearLayout>
    <LinearLayout
        android:id="@+id/tab_team"
        android:orientation="vertical"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:gravity="center_vertical|center_horizontal"
        android:layout_height="match_parent">

        <ImageView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_group_work_white_24dp"/>
        <TextView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lable"/>

    </LinearLayout>
    <LinearLayout
        android:id="@+id/tab_notification"
        android:orientation="vertical"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:gravity="center_vertical|center_horizontal"
        android:layout_height="match_parent">

        <ImageView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_notifications_white_24dp"/>
        <TextView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lable"/>

    </LinearLayout>

</LinearLayout>

上面添加的是在应用程序启动时启动的活动视图的 XML 代码。此活动在中心有一个框架布局。该框架布局显示一个片段,例如片段A。这是这个片段的 XML 视图代码。

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="#F8F8FF">


   <android.support.v7.widget.RecyclerView

    android:id="@+id/appHomeRecycleView"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

   </android.support.v7.widget.RecyclerView>

   <android.support.design.widget.FloatingActionButton
    android:id="@+id/xyz1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="16dp"
    android:scaleType="center"
    android:src="@drawable/ic_mode_edit_white_24dp" />

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

【问题讨论】:

  • 状态栏或操作栏/工具栏?
  • 状态栏,Jared,我们可以在其中找到 wifi 或移动信号塔的信号。
  • 支持库不改变状态栏高度
  • 谢谢。但是在升级库之前,相同的代码运行良好。你能告诉我找到根本原因的方法吗?
  • 请给我们看两个版本的截图。在此过程中,请在问题中添加您的活动布局。 (顺便说一句,状态栏在 Android 6 之前为 25dp,在 Android 6 之后为 24dp。)

标签: android android-5.1.1-lollipop


【解决方案1】:

一般来说,您应该假定状态栏的高度是固定的(尤其是针对不同制造商的旧设备时)。我曾经这样做并后悔了:p AFAIK ScrimInsetsFrameLayout(或类似的)是去这里的方式,请参阅https://github.com/google/iosched/blob/master/android/src/main/java/com/google/samples/apps/iosched/ui/widget/ScrimInsetsFrameLayout.java

【讨论】:

    【解决方案2】:

    感谢您的回复。我为此工作了10多个小时,终于找到了解决方案。这是解决方案:

    你可以在fragmentA布局XML文件中看到一个参数:

        android:fitsSystemWindows="true"
    

    将此参数更改为false:

        android:fitsSystemWindows="false"
    

    坦率地说,我不明白为什么这不适用于新库 23.2.1,但它在 23.1.1 版本中运行良好。

    希望这对其他人有所帮助。

    谢谢

    普拉巴卡

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-13
      • 1970-01-01
      • 2013-03-27
      • 2017-06-01
      • 1970-01-01
      相关资源
      最近更新 更多