Shape Drawables on Samsung devices default to black background

丶灬走出姿态 提交于 2019-11-30 00:18:39

问题


So I'm developing using a Samsung Note 2 device and for some reason when I create this drawable

<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<corners android:radius="5dp" />

<stroke
    android:width="1dp"
    android:color="@color/grey_light" />
</shape>

and apply it as a background to a LinearLayout, it makes the background black,

If I remove the background attribute of the LinearLayout altogether it stays transparent, only when I apply a drawable to it does it turn black.

but if I add

<solid android:color="@android:color/transparent" />

to the top of the drawable XML, it removes the black.

Now I know devices can have their own default themes but this seems like weird behaviour, is there any way I could get rid of it (/default the background to transparent) so that I don't have to add this to more of my drawables?

Note: it works fine on Nexus 7, HTC One, its only on Samsung devices that this happens.


回答1:


I ran into this a couple of months ago. To the best of my knowledge, Samsung changed something in Android's code so now you have to define the solid tag. Just add the solid tag to your drawables.



来源:https://stackoverflow.com/questions/21333286/shape-drawables-on-samsung-devices-default-to-black-background

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!