相关疑难解决方法(0)

Android:我可以创建一个不是矩形的视图/画布,但是例如圆形吗?

我有一个圆形的视图,悬浮在上面( - >在z轴方向从屏幕出来)的主要内容.当有人点击屏幕时,我想要选择主要内容,或者当它覆盖主视图时,视图悬停在上方.

到目前为止完美无缺.我在透明帆布上有一个圆形物品.这意味着您可以看到该圆圈之外的所有背景.但是,您无法选择它,因为它仍然是悬停的画布,只有透明的颜料.

现在我想知道,要解决这个问题,是否有可能使视图/画布本身呈圆形?


更新

我添加了一个图像,以便更好地解释我试图实现的目标. 替代文字

android canvas view rounding

12
推荐指数
1
解决办法
2531
查看次数

Android点击PopupWindow

我创建了一个扩展popupwindow的类.它的构造函数看起来如下所示

super(builder.context.get());

this.setWindowLayoutMode(ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT);
setFocusable(true);
setBackgroundDrawable(new BitmapDrawable());
setTouchInterceptor(onTouchListener);
FrameLayout frameLayout = new FrameLayout(builder.context.get());
LayoutInflater inflater = (LayoutInflater) builder.context.get().getSystemService(
        Context.LAYOUT_INFLATER_SERVICE);
View overlayBase = inflater.inflate(R.layout.tutorial_view_items, null, false);
frameLayout.addView(builder.backgroundView);
frameLayout.addView(overlayBase);
setContentView(frameLayout);
Run Code Online (Sandbox Code Playgroud)

onTouchListener如下所示:

private OnTouchListener onTouchListener = new OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        float x = event.getX();
        float y = event.getY();
        Log.d(TAG, "Received");

        if (Math.pow(x - coordinates[0], 2) + Math.pow((y - coordinates[1]), 2) < Math.pow(radius, 2)) {
            Log.d(TAG, "bubbled through");
            return false;
        }
        return true;
    }
};
Run Code Online (Sandbox Code Playgroud)

我打电话来实际显示弹出窗口 SomePopupWindow.showAtLocation(SomeActivity.getWindow().getDecorView().getRootView(), …

android z-order onclicklistener

10
推荐指数
1
解决办法
5028
查看次数

标签 统计

android ×2

canvas ×1

onclicklistener ×1

rounding ×1

view ×1

z-order ×1