there is the snippet of my layout file:
layout_1
with backgound #e9e9e9
<LinearLayout android:id="@+id/layout_1"
android:layout_width="wrap_content"
android:background="#e9e9e9"
android:layout_height="wrap_content"
>
...
<com.test.android.CustomView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
...
</LinerLayout>
<LinearLayout android:id="@+id/layout_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
...
<com.test.android.CustomView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
...
</LinerLayout>
There is my custom drawable and CustomView classes snippets. The top one partly cover the bottom one.
public class NodeDrawable extends Drawable {
//...
protected ShapeDrawable shapeDrawableBottom;
protected ShapeDrawable shapeDrawableTop;
@Override
public void draw(Canvas canvas) {
Paint circlePaint = shapeDrawableBottom.getPaint();
circlePaint.setColor(DEFAULT_COLOR_BOTTOM);//DEFAULT_COLOR_BOTTOM = 0xe2f5ff
circlePaint.setFlags(Paint.ANTI_ALIAS_FLAG);
shapeDrawableBottom.setBounds();
shapeDrawableBottom.draw(canvas);
Paint circlePaint = shapeDrawableTop.getPaint();
circlePaint.setColor(DEFAULT_COLOR_TOP);//DEFAULT_COLOR_TOP = 0x1f8fd2
circlePaint.setFlags(Paint.ANTI_ALIAS_FLAG);
shapeDrawableBottom.setBounds();
shapeDrawableTop.draw(canvas);
}
//...
}
public class CustomView extends View {
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
buildDrawables();
}
private void buildDrawables() {
mCustomDrawable = new CustomDrawable();
}
}
But the layout background have an effect on the bottom one and the bottom one effect the top one either.
How can i ensure them displayed in correct RGB color, what i should do with the RGBA's alpha value? I have tried set the color to 0xe2f5ff with alpha value 1, but i think the layout backgound still have an effect on the bottom color...
circlePaint.setColor(Color.parseColor("#00FFFFFF"));
where first 2 digit is for Alpha. 00 to FF