How can I dim my background when custom View is showing? In my Ac开发者_JAVA百科tivity I have Relative Layout with some photo in background. When user do some action - FrameLayout appears in center of screen - and then I want make it to act like dialog - dim everything under framelayout.
How can I achieve that?
add this view over it.. it ll help you..
public class TransparentPanel extends LinearLayout {
private Paint innerPaint;
public TransparentPanel(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public TransparentPanel(Context context) {
super(context);
init();
}
private void init() {
innerPaint = new Paint();
innerPaint.setARGB(180, 75, 75, 75);
}
public void setInnerPaint(Paint innerPaint) {
this.innerPaint = innerPaint;
}
@Override
protected void dispatchDraw(Canvas canvas) {
RectF drawRect = new RectF();
drawRect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
canvas.drawRoundRect(drawRect, 5, 5, innerPaint);
super.dispatchDraw(canvas);
}
}
精彩评论