Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set background for all activities?

How to set background for all activities in adnroid application and keep it's aspect ratio?

I am using android:windowBackground in style, but I don't know, how to keep aspect ratio for my background image.

Is there only way to add ImageView with background for all activities manually?

like image 951
Alexey Markov Avatar asked Oct 18 '22 07:10

Alexey Markov


1 Answers

You might be able to set the background in the styles.xml

<style name="AppTheme.FullBackground" parent="AppTheme">
    <item name="android:background">#757575</item>
</style>

(Where AppTheme might be a theme you already defined, and I just used a grey color there, but it can be a drawable)

Then add to your Manifest

<activity 
    android:name=".FooActivity"
    android:theme="@style/AppTheme.FullBackground">
</activity>

Since you have to add activities to the Manifest anyway, this is a good way to check if all the activities have the background. You, of course, could still extend the BaseActivity and only have the BaseActivity class maintain the theme setting.

like image 83
OneCricketeer Avatar answered Nov 17 '22 04:11

OneCricketeer