I am trying to display a static background image (sort of the backdrop of an app) and have found that this can be done either by using the "android:background" option in my FrameLayout OR within the onDraw() method where this is done via the canvas.drawBitmap() at every entry.
Could someone please explain the difference between using these approaches and which offers better performance?
<resources> <style parent="android:Theme.NoTitleBar" name="Theme.BG"> <item name="android:windowBackground">@drawable/background_image</item> </style> </resources>
I wrote a style with this attribute and applied to the whole application via the manifest. I extended the NoTitleTheme, You can extend any of the default themes in android
<application android:theme="@style/Theme.BG" android:label="@string/app_name" android:icon="@drawable/app_iconicon">
This is easily the most efficient way to apply a background to the whole app..
Setting the background to each Framelayout means writing more of code. And doing it in the onDraw requires you to extend a view or any other component. You can set teh background by these methods but the window background of the app is still drawn. But when you set the window backgorund like above, the default background is not drawn, and possibly you save the complexity of writing more code.