What's the meaning of v19 behind drawable? for example: drawable-hdpi-v19?
Thanks!
Table 2 in doc describes all possible options for res folders.
v19 means at least API19 (4.4)
It describes the API Level. In this case API 19+ (Android 4.4)
That is probably because of the updated Design guidelines. For example touch:
Touch feedback
Before Android KitKat, Android's default touch feedback color was a
vibrant blue. Every touch resulted in a jolt of high-contrast color,
in a shade that might not have mixed well with your brand's color(s).
In Android KitKat and beyond, touch feedback is subtle: when something
is touched, by default its background color slightly darkens or
lightens. This provides two benefits: (1) sprinkles of encouragement
are more pleasant than jolts, and (2) incorporating your branding is
much easier because the default touch feedback works with whatever hue
you choose. Check the updated Touch Feedback page for more details.
The API level of the resource (v19 -> 19+ kitkat 4.4).
You could use it for drawable, values, xml etc. for every resource.
The API level supported by the device. For example, v1 for API level 1
(devices with Android 1.0 or higher) and v4 for API level 4 (devices
with Android 1.6 or higher). See the Android API levels document for
more information about these values.
Related
What would happen if we won't create a duplicate resource of the higher version for new attributes?
For example, ImageView's android:foreground attribute is not available on API level lower than 23. Android studio would recommend creating a resource override for higher API levels. What would happen if we won't create a new resource file and run it on lower APIs, for example, API 18?
Would the application crash or nothing would happen. I could not find relevant articles and didn't have access to a physical device with API lower than 23.
The short answer is that the attribute which is available only on a certain API and above will have no effect on lower APIs. In essence, it will be ignored.
Here is what Android Studio lint says about this situation regarding android:foreground when the minimum API is set to API 18:
So, the foreground attribute will be identified and used on APIs 23 and up but ignored on anything below API 23.
Just to make sure, I ran the layout on an API 18 emulator where the test app did not crash but the foreground color did not show and on an API 28 emulator where the foreground color did show.
I am developing an app, however, I have noticed on phones that have edge-to-edge screens, the black notch at the top blocks out some of the features I've added in (for instance, information on the action bar).
I know there are simple fixes such as using
<item name="android:windowLayoutInDisplayCutoutMode">
shortEdges <!-- default, shortEdges, never -->
</item>
within the activity style, however, I have noticed that the incision of this requires a minimum API level of 27, which is much higher than the minimum of 14 I have been trying to maintain, and I don't want to cut out that high of a percentage of the market.
Do any of you know how to deal with edge-to-edge screen layouts without compromising the minimum API level?
I would advise you to just use newer API, as since then new models with notch started showing up on market (thus Android introduced that API), keeping API 14 as min. You can still support older devices without calling non-existing methods from newer APIs. As you have here only one attribute in XML - these aren't resolved on older OS versions, but don't break nothing
PS. Note that before Android introduced this API there was some freshly introduced devices with notch and you don't have any option for proper handling layout on them (too old for API, device manufacturer didn't provide any API either). But most (all?) of them got update to API27, so your issue may occur only on never-updated devices with "experimental" notch
By setting android:colorForeground in the theme, the main text colours are calculated based on this setting, i.e. android:textColorPrimary and android:textColorSecondary.
I have tested this with API 23 and API 27. In API 23 it is not working and the text colours are based on white. In API 27 it is working as expected.
Is this a known bug?
Is there an easy workaround?
How extended is the bug on different versions of the API?
Thank you very much.
As far as I can tell this is rather an issue of Android Studio. The Layout Editor is showing a color calculation behaviour for API 23, wich seems to be available from API 26 onwards.
The color requires an attribute primaryContentAlpha which is available for API 26.
I still have to find out, how the fallback behaves for lower API and if I can fix this by a support library.
See: Support library for text color behaviour of API 26?
I'm currently writing an android app. I want the minimum sdk to support jelly bean devices, so I set the min sdk to 17. Everything works, but the pressing animation on buttons and etc. are all the older animations. Is it possible to have the new lollipop circle animation? Or at least have it on 5.0 devices.
If you need anything, comment.
I assume you mean ripple effect. There are several libraries that can handle ripple : traex/RippleEffect, siriscac/RippleView and balysv/material-ripple all supporting API14 and up from what I can see.
If you wish to use whole material components, not just ripple I'd recommend rey5137/material or navasmdc/MaterialDesignLibrary. Those contain material design buttons, switches and much more ready to use.
My supported OS versions are >= 2.2
Now i want to use some >= 4.0 views in my application, So whats the best way to load different layouts according to different os? say I want to use default time picker in android os < 4.0 and holo theme time picker in android >= 4.0
Is it possible? whats the best way?
See this article.
Basically you can define different layouts per API level (and many other qualifiers). In your case, you would have:
res/layout/my_layout.xml (with the "old" controls).
res/layout-v15/my_layout.xml (with the "new" controls).
A device with API level 15 (i.e. ICS) or greater will use the "new" layout, while those with a lower API level will use the other one.
To simplify your code (e.g. usage of findViewById()) make sure that corresponding views in both layouts have the same ids.