当前位置: 首页 > 知识库问答 >
问题:

ANDROID:应用栏或状态栏与主活动不一样

常飞翼
2023-03-14

所以我希望我的应用程序栏或状态栏有相同的风格。

以下是我的主要活动:

这是我的第二个活动,有不同的应用程序栏或状态栏

<com.google.android.material.appbar.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</com.google.android.material.appbar.AppBarLayout>
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<application
    android:name=".app.AppController"
    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">
    <activity
        android:name=".activity.ApplicationActivity"
        android:label="@string/title_activity_application"
        android:theme="@style/AppTheme.NoActionBar"></activity>
    <activity android:name=".activity.ProfileActivity" />
    <activity android:name=".activity.ResetPasswordActivity" />
    <activity android:name=".activity.SignupActivity" />
    <activity android:name=".activity.LoginActivity" />
    <activity
        android:name=".activity.MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".activity.AboutUsActivity"
        android:label="@string/activity_title_about_us" />
    <activity
        android:name=".activity.PrivacyPolicyActivity"
        android:label="@string/activity_title_privacy_policy" />
</application>

这是activity_main.xml

<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

<include
    layout="@layout/app_bar_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<com.google.android.material.navigation.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_main"
    app:menu="@menu/activity_main_drawer" />

共有1个答案

吉栋
2023-03-14
<style name="AppTheme.NoActionBar">
   <item name="colorPrimary">@color/colorPrimary</item>
   <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
   <item name="colorAccent">@color/colorAccent</item>
   <item name="windowActionBar">false</item>
   <item name="windowNoTitle">true</item>
</style>
 类似资料:
  • 我在这个问题上做了一些研究,但我找不到一个完整的解决方案,所以,一步一步,通过一些尝试和错误,我终于找到了我们如何实现这些结果:拥有一个透明或彩色的和。看我下面的回答。

  • 问题内容: 我有bootstrap v3。 我在菜单上使用时,它不会切换。我知道该如何使用并建立点击功能,但我认为该功能应包含在引导程序中?那么也许是JavaScript问题? 这是我包含的js / css / bootstrap文件的标头: 这是我的代码: 我可以正确设置吗? (在不相关的注释上,但可能相关吗?当菜单移动时,我单击菜单按钮,它将折叠。尽管再次按下并不会使其崩溃。因此,此问题与另一

  • 本文向大家介绍Android自定义状态栏颜色与应用标题栏颜色一致,包括了Android自定义状态栏颜色与应用标题栏颜色一致的使用技巧和注意事项,需要的朋友参考一下 每次看IOS上的应用,应用中状态栏的颜色总能与应用标题栏颜色保持一致,用户体验很不错,对于这种效果,像我这种好奇心强的人就会去看看那安卓是否可以呢?若是在安卓4.4之前,答案是否定的,但在4.4之后,谷歌允许开发者自定义状态栏背景颜色啦

  • 我想让我的活动全屏显示,上面有状态栏,如下图所示: 我在内部标签中使用了此代码: 但我的视角不是从状态栏开始的 如何使我的看起来像第一个?

  • 问题内容: 我是Android新手。我想在手机上制作 电池充电动画 ,例如,在屏幕的右上方,该小图标在充电时会上下颠倒,并以当前电池电量百分比停止显示。 到目前为止,在我的代码中,我已经能够移动它,但是它永远不会停止。 我想要的是让动画在不充电时停止播放或以当前电池电量百分比停止播放。 这是我在动画中的代码: 到目前为止,我可以获得电池状态,插头类型和电池的状况。 问题答案: 入门类也应实现停止逻

  • 我有一个带有。我们的客户要求我们根据从中选择的项目,动态更改此活动的操作栏颜色和相应的状态栏颜色。这很容易做到。然而,我的问题是,当我动态更改状态栏颜色时,我无法保持状态栏透明。当我打开抽屉时,彩色状态栏会覆盖抽屉布局的顶部,如下所示: 但是,我希望我的看起来像这样: 这我可以用下面的行做: 然而,我的问题不是我不能设置状态栏的透明度。我的问题是,状态栏和操作栏颜色的动态更改不适用于。我的状态栏颜