You Need To Use A Theme.appcompat Theme (or Descendant) With This Activity On Android
I have this in Activity : public class MainActivity extends AppCompatActivity implements FragmentDrawer.FragmentDrawerListener{ private Toolbar mToolbar; private Fragment
Solution 1:
All you need to do is add android:theme="@style/Theme.AppCompat.Light" to your application tag in the AndroidManifest.xml file.
Solution 2:
Change this
<stylename="MyMaterialTheme"parent="MyMaterialTheme.Base"></style><stylename="MyMaterialTheme.Base"parent="Theme.AppCompat.Light.DarkActionBar"><itemname="windowNoTitle">true</item><itemname="windowActionBar">false</item><itemname="colorPrimary">@color/colorPrimary</item><itemname="colorPrimaryDark">@color/colorPrimaryDark</item><itemname="colorAccent">@color/colorAccent</item></style>
to this
<stylename="MyMaterialTheme"parent="Theme.AppCompat.Light.DarkActionBar"><itemname="windowNoTitle">true</item><itemname="windowActionBar">false</item><itemname="colorPrimary">@color/colorPrimary</item><itemname="colorPrimaryDark">@color/colorPrimaryDark</item><itemname="colorAccent">@color/colorAccent</item></style>
Full code :
<resources><stylename="MyMaterialTheme"parent="Theme.AppCompat.Light.DarkActionBar"><itemname="windowNoTitle">true</item><itemname="windowActionBar">false</item><itemname="colorPrimary">@color/colorPrimary</item><itemname="colorPrimaryDark">@color/colorPrimaryDark</item><itemname="colorAccent">@color/colorAccent</item></style></resources>
and then clean
the project and rebuild
it.
Solution 3:
change these two lines
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);
Use these
setActionBar(mToolbar);
getActionBar().setDisplayShowHomeEnabled(true);
Solution 4:
If I understood correctly, You have already defined a style MyMaterialTheme
in values/styles.xml
.
Does Your most base theme extends one of the Theme.AppCompat.{Light,Dark}.NoActionBar
? For example:
<stylename="MyMaterialTheme.Base"parent="Theme.AppCompat.Light.NoActionBar">
Post a Comment for "You Need To Use A Theme.appcompat Theme (or Descendant) With This Activity On Android"