2

I'm having trouble modifying the default application theme in Android Studio.

As a really simple test I just want to remove the default ActionBar in a default starting project. I do this by setting a "NoActionBar" theme in the preview pane. When I run the application however, no changes are applied.

Is modifying the theme of an application in AndroidStudio through the preview pane the correct way of applying said theme to your application?

Are there any additional steps that need to be taken to apply the changes and if so, what are they? (if thats the case, its not exactly intuitive that changes in the preview pane don't show up in your actual application)

Prismatic
  • 3,338
  • 5
  • 36
  • 59

4 Answers4

2

If you want to remove the action bar then in your manifest file in activity tag enter <android:theme="@android:style/Theme.NoTitleBar">

and also you can start your activity like public class yourclass extends Activity instead of extends ActionBarActivity

Hope it helps ...

2

you should change theme in Manifest or activity class, something like this:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

Amir
  • 1,250
  • 18
  • 22
2

First, have a look at this answer https://stackoverflow.com/a/29001288/4188219

So, the selected theme for preview is just a way to let you know what effect the selected theme will be, but if you want use some theme to your app when run on device, you must define it in xml or code. That is to say, the preview theme does not affect the actual theme of app.

Community
  • 1
  • 1
Terry Liu
  • 601
  • 5
  • 8
  • When I edited the theme through the preview pane, the change was reflected in my Manifest. There's an entry that looks like: android:theme="@style/AppTheme", with the corresponding resource pointing to the correct theme. There's still no change in the actual application though. – Prismatic Mar 16 '15 at 08:06
  • @Pris the entry `android:theme="@style/AppTheme"` is defined in your project's res-->values-->styles.xml, it will not be changed when you select different theme in preview panel. – Terry Liu Mar 16 '15 at 08:12
  • It is changed when I select a different theme. The point is, I see that there's a theme applied to the application in the manifest but its not reflected on the device. EDIT: Never mind, I think you're right – Prismatic Mar 16 '15 at 08:15
  • @Pris I tried, but the style **AppTheme** in styles.xml, which is the actual theme for app is not changed when select different theme in preview panle...don't know what's your condition... – Terry Liu Mar 16 '15 at 08:30
  • It was my mistake, you're correct. The preview pane doesn't seem like a WYSIWYG editor and making the changes directly in the manifest made them appear on device. – Prismatic Mar 16 '15 at 08:34
  • @Pris :) you got it, take care and have fun in android world! – Terry Liu Mar 16 '15 at 08:37
0

The easiest way is to simply define the theme the entire application uses, by mentioning it in the manifest file, under the application tag as below, (Since I wanted a dark actionbar so I mentioned that)

  <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar">
pcsaunak
  • 289
  • 2
  • 12