Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Layout Preview Default Theme

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.

like image 589
Olexii Muraviov Avatar asked Jun 19 '18 08:06

Olexii Muraviov


People also ask

How do I set the default theme in Android Studio?

To change default themes go to File and click on Settings. A new Settings dialog will appear, like this. Under the Appearance & Behaviour -> Appearance, you will find Theme. Choose the right theme from the drop-down and click on Apply and then Ok.

Can I change Android studio theme?

In Android Studio, open themes. xml (app > res > values > themes > themes.

How do you preview layout?

The Layout Preview can be accessed by pressing the Preview tab on the right. XML layouts are probably the most frequently used resource in Android development. Chances are you have at least one layout file for every Activity you have in your project.

Where is my styles XML in Android Studio?

Defining Styles This XML file resides under res/values/ directory of your project and will have <resources> as the root node which is mandatory for the style file.


2 Answers

Click here and change theme to your theme.

Click here and change 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.

like image 105
Nabil Avatar answered Sep 28 '22 05:09

Nabil


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>
like image 38
Paruyr Avatar answered Sep 28 '22 05:09

Paruyr