Android 图书馆 activity 应该以自己的主题独立打开

Android library activity should open independently with its own theme

我想创建自己的库,其中包含常用的功能流程。这样它就可以在运行时用于多个应用程序,只需导入我的库。

我正在关注 Android developer guide and some examples 创建图书馆。

我正在为我的图书馆定义主题是 Theme.AppCompat.Light.NoActionBar

使用我的库并定义主题的应用程序是 Theme.AppCompat.Light.DarkActionBar

所以我的问题是:当用户调用操作打开我的库时,库应该在没有操作栏的情况下打开,但它在应用程序操作下方打开 bar/toolbar。

我正在添加图片,它将描述我的实际问题:

是否有任何设置可以帮助我使用我定义的主题打开我的图书馆?

你可以在onCreate下面使用。

 getSupportActionBar().hide()

在styles.xml中类似这样:

   <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

Note:- Need to add below condition, in case of library. Because some application might already have NoActionBar theme.

    if (getSupportActionBar() != null) {
        getSupportActionBar().hide();
    }