状态栏与工具栏重叠,并且在重新创建后可以正常显示

时间:2019-01-10 12:13:15

标签: android toolbar statusbar

我的工具栏位于状态栏/状态栏下方,与工具栏重叠。经过另一项活动后又回到该活动,一切都很好。

情况就是这样,a screenshot

已经尝试使用

android:fitsSystemWindows =“ true”。

添加为真 主题

和  也是假的,

对我没有任何作用

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:elevation="4dp"
            app:theme="@style/MyActionBar" />

        <ProgressBar
            android:id="@+id/webViewProgressBar"
            style="@style/Widget.AppCompat.ProgressBar"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal"
            android:outlineAmbientShadowColor="@color/crimson"
            android:visibility="gone" />

        <WebView
            android:id="@+id/webViewID"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="false" />

    </LinearLayout>


    <RelativeLayout
        android:id="@+id/rlNotificLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginTop="50dp"
        android:background="@color/black"
        android:padding="7dp"
        android:visibility="gone">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/listView_Notific_Link"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#00c4c3bf"
            android:divider="#00c4c3bf"
            android:dividerHeight="7dp"
            android:paddingLeft="2dp"
            android:paddingRight="2dp"
            android:paddingBottom="7dp"
            android:scrollbars="vertical" />
    </RelativeLayout>

</RelativeLayout>
  

Style.xml

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/crimson_dark</item>
    <item name="android:windowDisablePreview">true</item>
    <item name="colorPrimaryDark">@color/colorPrimary</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>

<style name="MyActionBar" parent="Theme.AppCompat.NoActionBar">
    <item name="actionMenuTextColor">@android:color/white</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>

<style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="android:background">#f1f0f0</item>
</style>

<style name="FullscreenTheme" parent="AppTheme">
    <item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
    <item name="android:windowActionBarOverlay">true</item>
    <item name="android:windowBackground">@null</item>
    <item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
    <item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>

<style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
    <item name="android:background">@color/black_overlay</item>
</style>

  

清单

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="ANDROID.PERMISSION.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />

<uses-feature
    android:name="android.hardware.camera"
    android:required="false" />
<uses-feature
    android:name="android.hardware.camera.autofocus"
    android:required="false" />
<uses-feature
    android:name="android.hardware.camera.flash"
    android:required="false" />

<application
    android:name=".LeadManagerBaseApp"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <service android:name=".CallRecording.TrackDeviceService" />

    <receiver
        android:name=".CallRecording.DeviceAdmin"
        android:permission="android.permission.BIND_DEVICE_ADMIN">
        <meta-data
            android:name="android.app.device_admin"
            android:resource="@xml/my_admin" />

        <intent-filter>
            <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
            <action android:name="android.app.action.DEVICE_ADMIN_DISABLED" />
            <action android:name="android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED" />
        </intent-filter>
    </receiver>

    <service
        android:name=".FCMNotificationServices.FirebaseInstanceIdService"
        android:stopWithTask="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

    <meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/car5" />
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/colorAccent" />

    <activity
        android:name=".login"
        android:noHistory="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <service
        android:name=".NotificationService"
        android:enabled="true"
        android:exported="false" />
    <service
        android:name=".NotificationServiceTwo"
        android:enabled="true"
        android:exported="false" />

    <receiver
        android:name=".NotificationReceiver"
        android:enabled="true">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.PACKAGE_ADDED" />
        </intent-filter>
    </receiver>

    <activity android:name=".MainActivity" />
    <activity
        android:name=".AboutActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/title_activity_about"
        android:theme="@style/FullscreenTheme"></activity>
</application>

有什么办法可以解决这个问题?

4 个答案:

答案 0 :(得分:0)

好,尝试从styles.xml中删除此行代码,或将其设置为false

    <item name="android:windowDrawsSystemBarBackgrounds">true</item>

答案 1 :(得分:0)

您可以在工具栏的父级布局(LinearLayout)上尝试使用“ android:fitsSystemWindows =“ true”“属性

答案 2 :(得分:-1)

我认为您的布局中有2个滚动容器,因此请使用嵌套的scrollview。

将webview和recyclerview父级布局放置在嵌套的scrollview容器下。

答案 3 :(得分:-1)

我认为您正在尝试进行全屏活动,因为我看到您已经用过

android:theme="@style/FullscreenTheme"

在清单中添加AboutActivity属性。要使活动进入全屏状态,请在Activity.java文件中使用此行。

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE); // To hide Title Bar if needed.

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        ...
        ...
        // Other Lines
        ...
        ...
    }