Reputation: 1191
I am trying to set shape color as image, but failing to do so. Maybe anyone could tell me how to do this in a proper way? I use this shape as my background for buttons.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:bottomRightRadius="7dp"
android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp"/>
<stroke
android:width="0.5dp"
android:color="#ff0000" />
<solid android:color= "@drawable/tableback1" />
</shape>
Upvotes: 0
Views: 314
Reputation: 30855
As you can set the starting two value for color as alpha with total 8 digits for example
#00ffaa44 // here is the fully transparent
#88ffaa44 // semi transparent
#ffffaa44 // fully opaque
you can maintain your color with alpha value as per your requirement
Upvotes: 2
Reputation: 16064
This is not possible in way you presented it in question.
As per documentation here: http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape solid.color
attribute value must be a color and not a drawable. This color is used as a fill for the whole shape. You're passing a drawable
which is seen here:
<solid android:color= "@drawable/tableback1" />
Instead it should be something along the lines:
<solid android:color="@color/background_color1" />
Or simply:
<solid android:color="#ffff0000" />
Upvotes: 1