I noticed that when creating various types of Activity when creating an application, different styles for checkboxes and spinners are screwed to them, when creating an Activation type of dialogue, their style is completely different for the elements. Where do these styles appear in the code and how can they be the same for all types of activations?

    1 answer 1

    Styles are specified in the manifest when declaring activations using the android: theme attribute

    In this manifest, they are listed in the application tag and in each activity tag.

    The attributes contain references to the styles resource.

    If the android: theme attribute is not specified in the activity tag, then the parent value of this attribute is taken (i.e. the value of the application theme tag android: theme)

    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.stackoverflow.ru"> <application android:theme="@style/AppTheme"> <activity android:name=".activity.ScrollingActivity" android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".activity.TagsActivity" android:label="@string/title_activity_tags" android:theme="@style/AppTheme.NoActionBar" /> <activity android:name=".activity.GalleryActivity" android:label="@string/title_activity_gallery" android:theme="@style/AppTheme.NoActionBar"></activity> </application> </manifest> 

    The style descriptions themselves are stored in resources (/res/values/styles.xml for example)

     <resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> </resources> 

    The main theme of the application is inherited from the Theme.AppCompat.Light.DarkActionBar theme using the parent attribute

    Theme properties are overridden inside the style tag.

    Read more about the styles and themes in the manual:

    https://developer.android.com/guide/topics/ui/themes.html


    You can also select a theme using the graphical interface in Android Studio.

    To do this, go to edit the activit and select the Design tab.

    In the panel at the top there will be a button for selecting a theme ( circled in red mark on the image )

    When you click on it, a selection window will appear.

    enter image description here