Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 978
McArthor Lee Avatar asked Dec 02 '25 06:12

McArthor Lee


1 Answers

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.

like image 55
Prateek Avatar answered Dec 03 '25 20:12

Prateek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!