问题
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