qkx
qkx

Reputation: 2563

How to style drawer (NavigationView) different theme than main activity?

I like to use dark theme in my activity, but I would like to have drawer in light theme.

Is it possible to set dark theme for activity AND light for drawer? Drawer should be light, but within dark activity.

Upvotes: 0

Views: 1094

Answers (2)

Neeraj Athalye
Neeraj Athalye

Reputation: 547

Simply add this to your navigation view XML

android:theme="@style/Theme.AppCompat.Light"

Upvotes: 2

Ryan Godlonton-Shaw
Ryan Godlonton-Shaw

Reputation: 584

To switch between themes dynamically you simply need to call setTheme before super onCreate like this:

public void onCreate(Bundle savedInstanceState) {
    setTheme(android.R.style.Theme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_two);
}

Upvotes: 0

Related Questions