我有这样的活动
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
tools:context=".WaitingActivity">
</FrameLayout>
Java代码是
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_waiting);
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
此活动使用对话框主题,因此整个屏幕将为70-80%的透明灰色。我需要在中心放置一个完整的透明圆圈,以便它后面的活动清晰可见。我该如何实现?
最佳答案
您可能对PortDuff.Mode感兴趣。它可以用于为重叠视图设置不同的传输模式。 XOR属性可用于在其他全屏布局中戳圆形孔,以使下面的内容可见。
https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html