开发者

How can I dim the backround view when a custom View is displayed

开发者 https://www.devze.com 2023-04-08 02:43 出处:网络
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

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);
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消