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.
A drawable resource is a general concept for a graphic that can be drawn to the screen and which you can retrieve with APIs such as getDrawable(int) or apply to another XML resource with attributes such as android:drawable and android:icon . There are several different types of drawables: Bitmap File.
A ShapeDrawable takes a Shape object and manages its presence on the screen. If no Shape is given, then the ShapeDrawable will default to a RectShape . This object can be defined in an XML file with the <shape> element.
Stroke (outline around the shape) Sometimes you want an outline around your shape and to do that you can use the stroke tag. You can specify the width and color of the outline using android:width and android:color.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With