Change the project theme in Android Studio?

前端 未结 3 1463
眼角桃花
眼角桃花 2021-02-02 07:08

I created some project using the light theme and now I want to change it to dark and I can\'t figure out how to do that. BTW, I\'m not asking on how to do it in code, just how t

相关标签:
3条回答
  • 2021-02-02 07:14

    In Manifest theme sets with style name (AppTheme and myDialog)/ You can set new styles in styles.xml

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MyActivity2"
            android:label="@string/title_activity_my_activity2"
            android:theme="@style/myDialog"
            >
        </activity>
    </application>
    

    styles.xml example

    <resources>
    
    <!-- Base application theme. -->
    <style name="AppTheme" parent="android:Theme.Black">
        <!-- Customize your theme here. -->
    </style>
    
    <style name="myDialog" parent="android:Theme.Dialog">
    
    </style>
    

    In parent you set actualy the theme

    0 讨论(0)
  • 2021-02-02 07:28

    Note : This answer is now out-of-date. This changes the theme in "preview" only as @imjohnking and @john-ktejik pointed out. As @Shahzeb mentioned, theme can modified in res>values>styles

    Android Studio 0.8.2 provides a slightly easier way to change the theme. In the preview window, you can select the theme of "Holo.Light.DarkActionBar" by clicking on the theme combo box just above the phone.enter image description here

    Or do a ctrl + click on the @style/AppTheme in the Android manifest file. It will open styles.xml file where you can change the parent attribute of the style tag.

    • Theme.Holo for a "dark" theme.
    • Theme.Holo.Light for a "light" theme.

    When using the Support Library, you must instead use the Theme.AppCompat themes:

    • Theme.AppCompat for the "dark" theme.
    • Theme.AppCompat.Light for the "light" theme.
    • Theme.AppCompat.Light.DarkActionBar for the light theme with a dark action bar.

    Source http://forums.udacity.com/questions/100200635/choosing-theme-in-android-studio-08x

    0 讨论(0)
  • 2021-02-02 07:37

    In the AndroidManifest.xml, under the application tag, you can set the theme of your choice. To customize the theme, press Ctrl + Click on android:theme = "@style/AppTheme" in the Android manifest file. It will open styles.xml file where you can change the parent attribute of the style tag.

    At parent= in styles.xml you can browse all available styles by using auto-complete inside the "". E.g. try parent="Theme." with your cursor right after the . and then pressing Ctrl + Space.

    You can also preview themes in the preview window in Android Studio.

    0 讨论(0)
提交回复
热议问题