Android Studio Layout Preview Default Theme - android

Maybe this is well known option in Android Studio but I couldn't find it and Google has not helped me with this :( Every time I open a layout preview in Android Studio it's applying Material.Light theme to every layout in my project and I need manually apply my own theme to see how it will look like in a real app. Does somebody know how to change default Material.Light theme to be my custom theme when previewing layout with Layout Previewer in Android Studio so I don't need to apply it manually every time?
Thanks in advance.

Click here and change theme to your theme.
If you want a single theme to always open, give
android:theme="#style/YourTheme" in your <application> tag in Manifest file.
From next time onwards, when you create a new xml file, this will be your default theme.

You need to provide default theme on application tag in AndroidManifest.xml file. If you don't provide android:theme="#style/{themeName} there will be added Material.Light default theme.
Please check example of code snippet from my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypackage.iqall" >
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/iqall_main"
android:label="#string/app_name"
android:logo="#drawable/logo"
android:theme="#style/AppTheme" <!--in Preview you will see this as default preview-->
android:name=".IQallApp">
</application>
</manifest>

In all your manifests (in all modules), set
<application android:theme="#Theme/mainTheme">
</application
If you use Splashscreen theme (official way)
in your App module,
<application
android:theme="#style/SplashTheme"
tools:replace="android:theme">
</application>
AND RESTART Android Studio (very important)

Related

Android activity theme changes every time I restart Android Studio

Every time I restart Android Studio, the theme of all the activities get changed to either "Theme" or "Light", whereas I want to keep the theme as "AppTheme.NoActionBar".
I have included the line:
android:theme="#style/AppTheme.NoActionBar" in my android manifest file.
Be sure which theme is defined in you mainifest, in the part where you define your application:
<application
android:name=".ExampleApp"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
...
This is the theme of your application, if you want a specific theme in your activity, you have to set:
android:theme ="#android:style/AppTheme.NoActionBar"/>
into your activity tags:
<activity
android:theme ="#android:style/AppTheme.NoActionBar"/>
...

Is the application tag inside the AndroidManifest the good place to specify a theme?

I'm looking at the best way to specify the Holo.Light theme for my entire application.
Is the tag the best place to specify that theme?
My code looks like that :
...
<uses-sdk android:minSdkVersion="14"
android:targetSdkVersion="19"/>
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#android:style/Theme.Holo.Light">
<activity
...
Yes it is according to this:
http://developer.android.com/guide/topics/manifest/application-element.html
quote:
android:theme
A reference to a style resource defining a default theme for all activities in the application. Individual activities can override the default by setting their own theme attributes. For more information, see the Styles and Themes developer guide.
more info on themes:
http://developer.android.com/guide/topics/ui/themes.html
As noted above, its not necessary to add it to each activity, when you want your whole application to be in one style you just add it to the application tag.

How to change app default theme to a different app theme?

I have an Android app that has a default theme of Holo.Light but I want to change it to Theme.Black.I tried to do this by changing the style tag in the manifest android:theme="#style/AppTheme" to Theme.Black but it cannot be found.Is there extra steps I have to take in changing the theme?
Actually you should define your styles in res/values/styles.xml. I guess now you've got the following configuration:
<style name="AppBaseTheme" parent="android:Theme.Holo.Light"/>
<style name="AppTheme" parent="AppBaseTheme"/>
so if you want to use Theme.Black then change AppBaseTheme parent to android:Theme.Black or you could change app style directly in manifest file like this - android:theme="#android:style/Theme.Black". You must be lacking android namespace before style tag.
You can read more about styles and themes here.
To change your application to a different built-in theme, just add this line under application tag in your app's manifest.xml file.
Example:
<application
android:theme="#android:style/Theme.Holo"/>
<application
android:theme="#android:style/Theme.Holo.Light"/>
<application
android:theme="#android:style/Theme.Black"/>
<application
android:theme="#android:style/Theme.DeviceDefault"/>
If you set style to DeviceDefault it will require min SDK version 14, but if you won't add a style, it will set to the device default anyway.
<uses-sdk
android:minSdkVersion="14"/>
If you are trying to reference an android style, you need to put "android:" in there
android:theme="#android:style/Theme.Black"
If that doesn't solve it, you may need to edit your question with the full manifest file, so we can see more details
Or try to check your mainActivity.xml you make sure that this one
xmlns:app="http://schemas.android.com/apk/res-auto"hereis included

How to keep 4.1 theme & remove TitleBar in Android?

When I created new Android application in Eclipse.In its AndroidManifest.xml the theme set to application isandroid:theme="#style/AppTheme"& style.xml is as follows.
<resources>
<style name="AppTheme" parent="android:Theme.Light" />
</resources>
& my screen appears like this.
I want to remove the TitleBar from app but want to show the theme of Android 4.1's.
For this I tried
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Light.NoTitleBar" >
Now my screen appears like this the TitleBar is removed but theme has changed.
Please help me to sort out this issue.
Use this instead : #android:style/Theme.Holo.NoActionBar.
Try out putting this in your manifest.
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"

Android theme set to black, but it is white in Android 4.1

I have tried both Theme.DeviceDefault and Theme.Black in my styles.xml, and both make my 2.1 emulator become black correctly, but on the 4.1 emulator it stays white...am I doing something wrong?
<resources>
<style name="AppTheme" parent="android:Theme.Black" />
</resources>
PS: I presume the drop-down for "Theme" at the top of the Graphical Layout is just showing me what it would look like, it's not some kind of setting that's going somewhere (for the app)?
The Android system always chooses the most special values folder that fits best to your device.
As example if you have a folder values and another folder values-v14 the Android system takes resources from the latter if the device is v14 or newer.
Please refer to the Android documentation for more information.
1.create new folder under res -> values-v13
2.create file style there and add this style :
<style name="AppTheme" parent="android:style/Theme.Holo.Light">
in your manifast use this style for your application like this
<application
android:name=".MainApp"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
that way on ICS version you use the Holo.light theme and pre ICS use the default you already created
Setting it via styles doesn't actually work, but if you set it explicitly for application it works.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black" >
By default 4.0 and 4.1 give us white background but you can change it to black I face the same problem some days ago, if your project theme is set to be black then probably you change the Title while creating project to "Main" by default its "MainActivity" but if you change it to "Main" it will give you black backgrount/
I don't know my answer is relevant to your question or not but i think you talking about this if i am not wrong.

Categories

Resources