Mushaheed Syed
Mushaheed Syed

Reputation: 683

What happens when we don't create a new layout for higher APIs

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.

Upvotes: 0

Views: 33

Answers (1)

Cheticamp
Cheticamp

Reputation: 62851

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:

enter image description here

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.

Upvotes: 1

Related Questions