Android 4.3 (api 18) application name/icon position display change? - android

Moi - working on my app I added an emulator for api 18 to go along with 17 and 16. FYI, I am emulating an N7.
All is well and consistent for 16 and 17. However, wtf with 18. My application title and its icon seem to be put in a layout slightly larger. This is noticable as the default application background overlays the light blue border I've tried to compare to screen captures and as best I can tell the placement of the icon and application title text are identical but the background extends an extra 4 or 5 pixels.
Has anyone else had this issue? TIA
To try to make things a bit more obvious I changed the application base theme to Holo.Light. On API 17, the application background color only shows behind the icon and the app name text. However, on API 18 the background covers a rectangular area the height of the title/action bar and slightly wider than the icon and title. My only styling (to this point) is
<style name="AppBaseTheme" parent="android:Theme.Holo">
<item name="android:background">#FF000024</item>
</style>
The desired behavior is that API 18 Holo (dark) looks the same as API 17 and 16.
API 17 Light API 17 Dark API 18 Dark API 18 Light
More info: I've used the android debug tools to verify that the actual layout element sizes are identical on api 16/17/18/19. However, API 18 and 19 have this issue with the background in the lanuncer icon area (android:id/home).

Related

Android: app area reduced after upgranding gradle to 7.4.0

I'm having a weird issue after I upgrated gradle to version 7.4.0 from 7.0.4.
basically it looks like the "app window" has shrink vertically, so some space appears above the navigation bar and it changes its color as seen below. it seems that the amount of space increases if the device has a taller form factor.
I can reproduce this issue only on devices with api >=26. also is not visible if the device is "short". for example is not visible on a Pixel 2 emulator or nexus 5 but is huge on a pixel 6.
below some visual examples:
normal look: ( pixel 3 api 33 emulator)
wrong look: (pixel 3 api 33 emulator)
wrong look: (pixel 3 api 33 emulator with gesture navigation)
wrong look: (physical pixel 6a with gesture navigation)
wrong look: (pixel 6 api 26 emulator)
the Layout Inspector only shows the correct app area down to the bottom navigation menu, so it looks like the system is adding the extra space. also bottom sheets begin above the added space.
so it looks like the app has a maximum aspect ratio and doesn't expand to the whole screen lenght
any idea what's going on?
I finally solved this by adding
android:resizeableActivity="true"
to my <application> tag thanks to this question.
However it remains a mistery how this was the culprit as the issue only appeared after upgrading gradle and also according to the documentation this attribute should default to true.

Splashscreen Icon not showing entirely

I use the new splashscreen api to add an evenly splashscreen to all android versions down to API Level 23.
Are there any requirements for the splash icon? Currently i try to use a svg and i thought it would be sized automatically on different screens. Does anyone experienced this aswell and has a workaround or knows those (hidden?) requirements?
I use the latest splashscreen api version (1.0.0-alpha02) and this is my theme:
<style name="SplashTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#color/colorPrimary</item>
<item name="windowSplashScreenAnimatedIcon">#drawable/ic_disney_wordmark</item>
<item name="postSplashScreenTheme">#style/AppTheme</item>
<item name="windowSplashScreenAnimationDuration">1000</item>
</style>
This is the ouput with the ic_disney_wordmark as example which is an svg:
Thanks for your help!
You must now size your icon layers using the following guidelines:
Both layers must be sized at 108 x 108 dp.
The inner 72 x 72 dp of the icon appears within the masked viewport.
The system reserves the outer 18 dp on each of the 4 sides to create interesting visual effects, such as parallax or pulsing.
Note:
As with adaptive icons, one-third of the foreground is masked (3).
The app icon (1) should be a vector drawable, and it can be static or
animated.
Source : Android Apaptive Icons , Android Splash Screen
Do what I did, create an icon as an image in Android Studio, a right-click on drawable then new/image asset, choose a source from your SVG, and then resize it to fit the circle (be visible), and that is all. Then point to the foreground part of the created file in your splash configuration.
You can also manually scale your SVG.
<vector>
<group
android:scaleY="0.5"
android:scaleX="0.5">
.
.
.
</group>
</vector>
PS: you also need to centre the icon using the "pivotX" and "pivotY"

Background gradient result in color banding

I tried to do some linear gradient on my background for my app, and it resulted with color banding.
What I did:
I created a shape called window_background_app.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="45"
android:endColor="#Fe005694"
android:startColor="#fe2D8ACC"
android:type="linear" />
</shape>
I used that shape in a style to apply to the background:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowBackground">#drawable/window_background_app</item>
</style>
</resources>
I used that style in the manifest of my app:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:name="generic_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
Problem
When starting my app, the background displayed some banding with the gradient background_with_banding
I found in similar questions, (for example this one) that I should:
Try to set dither to true for the background. Problem: use of dither is deprecated now.
To set the Pixelformat to PixelFormat.RGBA_8888. Problem: that did not change anything for me.
I got this problem on:
a OnePlus 5t Api 28 (real device)
Samsung S8, Api 28 (real device)
a Pixel 2 Api 24 (emulator)
a Pixel 2 Api 22 (emulator)
a Pixel C Api 27 (emulator)
The banding did not appear on:
Samsung Galaxy J3 Api 22 (real device)
Samsung SM-T533 Api 22 (real device)
Question
I'm not sure if the problem is due to updates on Android version or of from material (or both). And another problem I had is that a lot of solutions I could find online were quite old (most recent were around 2014).
So my question is:
Are there some new solutions for color banding on gradient since dither=true and pixelFormat=RGBA_8888 ?
I'm pretty sure dithering doesn't do anything if the pixel format is RGBA8888, and therefore cannot help with the banding between visually-adjacent 24bit RGB hues.
This is probably an Android limitation, which arises from the OpenGL limitation that dithering is only for lower bit depths than 32 bit. OpenGL is the backing implementation of Android's Views.
So, the solution might be using a PNG file for the gradient with dithering already built-in by your paint program.
Surprisingly, adding an alpha channel removed the banding completely in my case.
Just set the alpha value of all the colours to 99%, and this would completely remove the banding.
To set the alpha value, you can add FE to the beginning of the HEX value, like #FFFFFF to #FEFFFFFF
OR
Click on the little coloured square besides the line numbers in Android Studio, and then you can change the alpha value.

android: does ScrollView has different default backgrounds for different API level?

I have a ScrollView with some children inside.
For API 23, the ScrollView has a white background. But for API 22 and below, the background is gray. I didn't set background in xml or code. All remaining default. Activity and fragment also have default background in layout xml. Activity theme is Theme.Holo.Light.NoActionBar by default, and Theme.Material.Light.NoActionBar for v21.
I saw this on:
samsung note 5 with 6.0.0: white
android emulator Nexus 6P with 6.0.0: white
samsung s6 with 5.1.1: gray
android emulator Nexus 6P with 5.1.1: gray
Xiaomi 4 LTE with 4.4.4: gray
android emulator Nexus 6P with 4.4.4: gray
based on the above test, I guess the background related to API levels.
If I set background to white in xml, for API 22 and below, I can see white background.
Any ideas?
If you haven't provided an explicit color, it might take the color from the default theme of the device. It doesn't depend on the API level, but the device theme.
Therefore, its also possible that you might see different colors for the same API level on two different devices.
Hence, if you want to be consistent across all devices, its always recommended to set the color you want explicitly.
Try this in your styles for the same background in different android API:
<item name="android:windowBackground">#color/background</item>

Appwidget size calculation

It might be me, but when I calculate minimum app widget sizes according to the formula given on the android page I don't get the right widget widths; The formula is as follows:
width(n) = (70 x n) - 30
When I want to have a 5x1 widget, the correct width would be (5 * 70) - 30 = 320dp. However when testing this on a motorola Xoom it resolves to being a 4x1 widget. I've tested different values and 400dp seems good for 5x1 on the motorola xoom with Honeycomb, but then I'd test it on a regular Galaxy Tab with Gingerbread and then it resolves to a 6x1 (like one would expect).
So two questions here;
What difference between Gingerbread and Honeycomb am I overlooking?
Since I know ICS widget size no longer has padding between widgets, is there some rule of thumb here as well?
In my 4x1 widget, I used these dimensions for res/values/dimens.xml:
<!-- size = (74 x n) - 2 -->
<dimen name="appwidget_margin">0dp</dimen>
<dimen name="appwidget_min_width">294dp</dimen>
<dimen name="appwidget_min_height">72dp</dimen>
and for res/values-v14/dimens.xml:
<!-- size = (70 x n) - 30 -->
<dimen name="appwidget_margin">0dp</dimen>
<dimen name="appwidget_min_width">250dp</dimen>
<dimen name="appwidget_min_height">40dp</dimen>
I used widget templates pack for background images .
In official guide there is written that default margin in res/values/dimens.xml should be 8dp, but if I use 8dp, my widget is smaller than standard widgets on the desktop (google search, weather etc.). Thats's because margin for v1-v13 is built in the background image:
I tested it on HTC Desire, Nexus S, emulator Android 2.2 and emulator Android 2.3.3. With the templates pack backgrounds and configuration above, my widget's size is the same as other standard widgets and looks good on all devices I tested.
There is also problem with various launchers. I recommend this article to read: http://radleymarx.com/blog/app-widget-padding-margins-in-ics-android/
Not too many devices fully follow Google's advised formula. You're better off using several xml-xxx folders that can specify more accurate minWidth & minHeight that correspond to the varying screens & OSes.
Right now I four solely based on OS:
xml // standard
xml-v11 // Honeycomb grid
xml-v14 // ICS's new extra padding
xml-sw552dp-v14 // ICS tablet padding
But as I fine tune, I may have to add a few new folders for particular dpis or screens.
Quick update:
Only some devices use automatic padding. Samsung & HTC have custom UIs that use full-width widgets, so they override the OS padding on their launchers.
In ICS there isn't no padding, there is automatic padding. And the formula that you used is for ICS.
For older versions there is another formula:
num*74 - 2
note: if you target pre-Honeycomb (or don't specify targetSdkVersion while specifying a minSdkVersion prior to honeycomb) then the honeycomb grid (and ICS grid) calculations don't take effect. Downside of this is you miss out on newer OS features, but if you don't actually need them then keeping target pre-honeycomb will save the hassle of customised xml folders.

Categories

Resources