1

I have an Android project with Modules that provide specific functionality.

Now, if I define an Activity on the Module that extends from AppCompat and try to use it on the main app, the toolbar doesn't take the styles defined on the manifest (the activity is not using the main app theme).

So far I've tried:

  • Define the theme tag on the main application manifest.

    android:theme="@style/AppTheme"

  • Define the activity on the main application manifest and set the theme there.

    <activity android:name=".mymodule.views.MyActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:windowSoftInputMode="adjustResize" android:screenOrientation="nosensor" android:theme="@style/AppTheme"> </activity> 
  • Define the activity on the module manifest and set the theme there.

    <activity android:name=".views.MyActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:windowSoftInputMode="adjustResize" android:screenOrientation="nosensor" android:theme="@style/AppTheme"> </activity> 

My styles.xml file looks like this (for both the main app and the module):

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

The toolbar XML is the following:

<android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:theme="@style/AppTheme" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:theme="@style/AppTheme" /> 

I've tried both android:theme and app:theme to style specifically the Toolbar but still no change.

Any thoughts?

Thanks!

6
  • Could you try it with your complete package name in the name field? Commented Mar 16, 2016 at 16:53
  • I've tried but still doesn't work... Commented Mar 16, 2016 at 17:46
  • Put your xml file of the layout with the toolbar Commented Mar 16, 2016 at 19:21
  • Added the toolbar xml. I've tried to use android:theme and app:theme but without any luck. Besides the rest of the style is not applied for InputLayout, EditText and such. Commented Mar 16, 2016 at 19:30
  • Could you try it with a different parent theme? Theme.AppCompat.Light.DarkActionBar for example? Commented Mar 16, 2016 at 20:23

1 Answer 1

1

Ok, so i've found a solution.

I had to wrap the toolbar around an AppBarLayout and it worked. My guess is that this is an issue from AppCompat... but anyways that's the way it worked for me!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.