I have migrated my splash screen to Android splash screen to support android 12. App uses user theme based on color. The theme was set onCreate() method of activity with setTheme() method.
After migration, I can set only one theme through XML attribute "postSplashScreenTheme".
How to set "postSplashScreenTheme" programmatically.
Related
I have multiple themes in my android application. Now in navigation_graph or mobile_navigation (whatever you called it), I am not getting theme changing opposition as we have in layout.
Is there any way to remove default native Splash screen in Flutter. I want to show my own splash screen instead of default black screen.
Splash screen can't be provided through Flutter as iOS and Android both have a different way to show.
iOS: The default Flutter template includes an Xcode storyboard named LaunchScreen.storyboard that can be used to show your splash screen.
Android: The default Flutter project template includes a definition of a launch theme and a launched background. You can customize this by editing styles.xml, where you can define a theme whose windowBackground is set to the Drawable that should be displayed as the launch screen.
Source: https://flutter.dev/docs/development/ui/advanced/splash-screen
I'm using the windowBackground splash screen approach (I want the first visible impression to fit my apps theme) AND I allow to use custom themes in my app, so the window background can be changed I can't set a theme in my app with the correct windowBackground because the user can change this theme.
When opening my app, I will always see the default windowBackground color, coming from my light theme, the one I set in the manifest. My manifest looks like following:
<application
android:theme="#style/AppThemeLight" >
<activity
android:name=".activities.mvp.MainActivity"
android:label="#string/app_name">
</activity>
</application>
In my activity, I overwrite the theme like following:
#Override
public void onCreate(Bundle savedInstanceState)
{
setTheme(...); // setting user selected theme, AppThemeLight or AppThemeDark
super.onCreate(savedInstanceState);
}
When starting the app, I ALWAYS see the light splash screen comming from my "AppThemeLight", even if using setTheme(R.style.AppThemeDark) when creating the activity...
Can I somehow change the main theme of my application in code? Or any other trick to get this working correctly?
Try below thing will not shown light theme on startup and change your activity theme on user selection.
Remove application level theme from your manifest file.
Set theme from activity base on your user selection.
As I have tried setting theme from application object but it not taking that theme(I am not sure why).
But if you remove that theme from application (manifest). You will have to set theme for your all activities explicitly.
I'm making an app that retrieve a lot of images from some server. I'm tinting each item in my List using Palette library. When a choose one I open another activity to show details of this item.
I want to build a theme based on the selected theme to apply in detail activity.
Is there a way to programmatically build a theme based on a Palette from a Bitmap?
If it is about the color of material design, there is a solution.
Remember: You cannot change the modify those colors at runtime but you can switch between themes at activity start.
When an user select a color, apply corresponding style and restart activity. Otherwise, change some other colors like Google keep
To set theme .
super.onCreate(savedInstanceState);
setTheme(...style.YourTheme);
To restart activity: Call the recreate() method of the activity.
I am developing an Android application where I have set the following theme to one of my activities so that I have a nice translucent background.
android:theme="#android:style/Theme.Translucent.NoTitleBar"
This works pretty well with versions before 14 (ICS), but on ICS, although the activity is shown with translucent background, all the elements inside the activity start using Gingerbread theme. i.e. the buttons inside the activity are displayed with yellow highlight when selected instead of blue on ICS. Similarly, a spinner button when activated/clicked display the items as dialog instead of ICS popup/popdown style.
Can anyone please help me on how to get the translucent background along with the ICS theme?
To have the blue highlight from ICS and up you need to use a Holo theme, all other themes will render components as if they are being displayed on Gingerbread and below because that is how the theme is telling the system to render them.
You could extend the Holo theme of your choice and use the members from the translucent theme which will give you your desired effect on ICS and above.
The theme data is available in <android-sdk>/platforms/android-<API-level>/data/res/