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.
Related
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.
Is it posible to eliminate the actionbar seen on the "recent apps" screen?
My theme in the manifest is Theme.AppCompat.Light.NoActionBar and everything is good in my app screen... it looks like this:activity screen
But when i switch to the "recent apps" screen in the phone, it looks like this:
app manager screen
I tried to customize in java code, but when i call getActionBar() or getSupportActionBar(), it returns null, and i guess is because im using a noactionbar theme.
I don't think it is possible to remove the AppBar under app manager screen but you can certainly change the color of it.
Android will use <item name="colorPrimary">#color/colorPrimary</item> in your App Theme to select the color of AppBar under app manager screen or you can say header color.
You can either change that <item name="colorPrimary">#color/colorPrimary</item> to your desired color that you want but it will impact your whole app because android will use that primaryColor on many different places in your app.
An other option you have is to set that header color in your code using TaskDescription class. Code will be as follows -
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Bitmap bitmapIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
ActivityManager.TaskDescription taskDescription =
new ActivityManager.TaskDescription(getString(R.string.app_name), bitmapIcon, getColor(R.color.colorHeaderColor));
this.setTaskDescription(taskDescription);
// more code here........
}
}
Value of R.color.colorHeaderColor can be desired color. Result will be as follows -
Happy Coding !
It's not actually called an action bar but it is more like app label because it contains the name of the app and it's icon which notifies the user about which apps are currently on the backstack. Since it is feature (or a behaviour) in android UX it cannot be eliminated or removed.
If you made your app fullscreen, it should fix the problem. However, then it wouldn't show the status bar on top.
When creating custom ActionBar icons what happens if the user changes their theme to something that makes your icon unreadable? Do they have this kind of power?
Example: So say I make an icon for my ActionBar in Holo Dark, so that the icon will be a lighter shade of white. What if the user changes their theme to Holo Light (or can they in my app?), forcing my icon to not be readable because it is also close to the same color as its background? I'm just concerned that if I create a custom app it will not look proper to only certain people.
I have been trying to find something about this but my searches and Google's Iconography pages didn't really give me a clear answer.
Android allows setting a themes to application/activity in AndroidManifest.xml, and you can change theme theme dynamically. If a user change their system themes, it don't affect you application. If you want to change your application/activity themes, you should call setTheme() before setContentView() in Activity.onCreate()
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/
I want to change the look of my Android app's preference screen to white background and dark text color. It seems that I can change background color in the code. Is there a similar way to change text color of preferences in the code?
getListView().setBackgroundColor(Color.TRANSPARENT);
getListView().setCacheColorHint(Color.TRANSPARENT);
getListView().setBackgroundColor(Color.rgb(255, 255, 255));
The other way could be setting the activity's theme to light in the app's manifest:
android:theme="#android:style/Theme.Light"
However, this overrides the application's style, which currently is set to
android:theme="#android:style/Theme.NoTitleBar"
Thus, title bar is displayed in the preferences screen. I can try to remove the bar by
requestWindowFeature(Window.FEATURE_NO_TITLE);
The app then crashes (AndroidRuntimeException: requestFeature() must be called before adding content) when trying to open preferences.
Use Theme.Light.NoTitleBar :)