How to achieve Google's Android 12 app widgets backgrounds? - android

Android 12 came with the new app widget feature "device theming" using the system's default theme #android:style/Theme.DeviceDefault.DayNight.
Seeing a screenshot like the one below in the documentation I was expecting to see more of the theme colours to be picked up in my own widget:
Compared to both the screenshot above and Google's app widgets like the ones for the weather and Gmail I can hardly measure any colours being picked up.
I also tried out Material Design 3's way of doing it via Theme.Material3.DynamicColors.DayNight with the same result. The screenshot below shows the Material design example app widget vs Google's weather widget - running on an Android 12 Pixel 5 device.
What is that Google's app widgets do differently to pick up so much more colour from the device theme?

I got word about the system_accent1_* colours and the blog post https://medium.com/#xch3dx/using-material-you-in-your-app-15ec982eecb4 .
Using <item name="android:backgroundTint">#android:color/system_accent1_50</item> I finally got the same background colour as Google has for their widgets.

Related

Theme or coloring issue in android

I'm stuck in a unknown issue of coloring. I develop an food delivery application. I set the design of application, for example i take Food Menu screen. Actual output of screen :
I run the app on almost 6 mobiles include samsung, q-mobile, huawei. It works perfect.
But when i run the app on another random samsung mobile it show me the layout like this:
I don't know why this dark gray appear in boxes bakcground. This is happening in only one mobile of samsung. I'm confused because i also check on samsung on other mobile with same android version and it works fine.
The same thing was happening to me on my OnePlus phone. The solution I use was that I added background color for all component that was not using correct color on my OP phone. So in the case of CardView's that you have below, I added app:cardBackgroundColor property to CardView XML component view and it started to show just fine. I didn't investigate any further to know what was the reason behind this, but as you said, it almost certainly got to do something with a different Theme on that Samsung.

Android view elements appear black (only on OnePlus 6 with Android Pie)

I'm working on an MVVM Android application. When I run the app on an OnePlus 6 with Android Pie all views appear in a sort of "dark theme". All the CardViews, Spinners and Dialogs through the app have a black background out of nowhere.
I made a new app with a CardView and let it run on the OnePlus6. That app was normal with a white CardView background.
I also tried to build the app on lots of different phones but only on the OnePlus 6 this sudden "dark theme" appears.
The OnePlus 6 uses the light theme, so that can not be the problem.
Does anyone know where this comes from? What code can I upload to make things extra clear?
one plus 6 has his own theme engine so you have first to installs themes to the mobile using for example : "substratum" then it will be better.
The problem is with the develop options on the phone. I tried to turn that off and on and for a while it worked in the normal way.
I don't know why it turns to black but it has to do with the Developer Options.

forcing square app icon

I will set a square app icon for my Android App made with Android Studio.
I set my own app icon with File -> New -> Vector Asset
This creates a normal and a round app icon.
If I copy and rename (ic_launcher_round.png) the quadratic app icon and install it for example on OnePlus Launcher i get the round icon, too.
My Logo is square, so it is really ugly to see it round.
How I can force a quadratic app icon? Is this possible?
If I set only android:icon="#mipmap/ic_launcher" instead of this and android:roundIcon="#mipmap/ic_launcher_round" in my Manifest.xml nothing change.
Your app's icon will be rounded when a launcher decides to make it rounded.
The "launcher" is just another app, like yours, but it is not your app - it is separated completely from it, and you can't normally influence any process that is separated from your app's process, OS will forbid that.
Only sometimes you would be able to do something like that by utilizing some form of Inter Process Communication (IPC) offered by your OS, assuming of course that the process you want to communicate with is also 'willing to talk' with you [utilizes the same form of IPC to allow other process to change some of its behaviors].
Also the purpose of the Android Studio's wizard you used was to help you generate ready-to-use drawable files and it was just to save your time on making these drawables all by yourself in some image editor.
Any drawable set inside XML manifest file for being your app's round icon will be rounded a t the end and that is no matter how it actually looks. I don't think you can expect any currently available major launcher application to display some apps' icons as round and some as square. It would significantly harm its user experience.
I'm afraid you will have to adapt to this situation and make your square app's logo a little bit smaller and leave some empty space around it to allow end user's launcher app to draw a circle around this logo.
Here you can find official recommendations for designing Android apps' launcher icons: https://material.io/guidelines/style/icons.html#icons-icons-for-android and here you can read about the most current approach in a subject of Android apps' icons: Adaptive ones. Any other type of icon can be treated as 'legacy' and used only for compatability reasons when targeting APIs below 26.
Edit:
In the comments section OP mentioned some apps that do currently have square icons in their newest versions and that turned out to actually be a small UX design flaw of its developers.
Just as an example, I've downloaded Bytecoin app OP mentioned, and this is how it looks like on my phone, Android 7.0:
The red object in the corner has ben cut off. I think we can assume that every other app on the Google Play that displays there with square logo [which looks good in their store pages because Google Play allows square logos] will look bad when installed on phones with modern versions of launchers, especially api >=26.
If your target SDK is 26 and android device version is 8, the app icon will be round.
One of the ways to achieve this is (Not sure if it is the right/best way to do it)
In AndroidManifest.xml I had to set
android:targetSdkVersion=“20”
<uses-sdk android:minSdkVersion=“16" android:targetSdkVersion=“20” />
android:roundIcon=“#mipmap/ic_launcher_round”
<application android:hardwareAccelerated=“true” android:icon=“#mipmap/ic_launcher” android:label=“#string/app_name” android:roundIcon=“#mipmap/ic_launcher_round” android:supportsRtl=“true”>
Ensure the ic_launcher_round images are Squared one.
I used the android studio to generate adaptive and legacy icons…
I deleted the ic_launcher_round images generated by the android studio.
I copied ic_launcher images(Generally the Square icons) to ic_launcher_round.
Now my ic_launcher_round is Squared icons.
(ic_launcher_round.png, ic_launcher.png, icon.png) all of them are the same images
After making this changes, rebuild the app. Now you should see Square icon when you install the app.
Since Android 8.0 (Oreo)
The new way of designing app icons for Android now is described there :
Adaptive icons
Android 8.0 (API level 26) introduces adaptive launcher icons, which can display a variety of shapes across different device models.
When using adaptative icons, launcher icons have 2 layers : foreground and background (see Creating adaptive icons in XML).
The shape (round, square...) can vary depending of the system / launcher settings.
Before Android 8.0
Legacy icons can be generated this way : Create a legacy launcher icon

Android app doesn't show colors properly?

I tried some Material Design stuff based on the Google's design principles and I wanted to add some "Material colors". I chose the colors from Google's material color palette but my device showed the colors MUCH brighter than on the site. After that I picked up some colors from materialpalette.com but I had the same problem. I tested this with an Android 4.2 device.
Different colors rendering is due to phone hardware. Deal with it.

Android App Development - Theme Trouble

My first question :-)
So recently I took up app development, and was going through the tutorial posted here:
http://developer.android.com/training/basics/firstapp/index.html
I finished part 1 - "Building Your First App" and followed exactly every instruction.
According to the Google tutorial, the result should look like:
http://developer.android.com/images/training/firstapp/firstapp.png
However, when I ran the app using the emulator (Platform 4.2.2, API level 17), the app was missing the theme, meaning only the black bar with the app icon and a white background.
I don't know what is wrong, when I created the application (project), I made sure to set the theme to "Holo Light with Dark Action Bar" as instructed in the tutorial.
Is it because I am running the app in the emulator? If not, then what do you think I should do to fix the issue?
Thank you very much :-)
However, when I ran the app using the emulator (Platform 4.2.2, API
level 17), the app was missing the theme, meaning only the black bar
with the app icon and a white background.
Theme.Holo.Light.DarkActionBar is a light theme with a dark ActionBar, so your app does not look wrong. If you want a dark theme, then use Theme.Holo.

Categories

Resources