悬浮球踩过的坑
公司的SDK要写一个登录界面,里面涉及到悬浮球,但是不能申请权限。起初想到的方案是利用游戏的一个Activity,通过下面代码找到容器view
View root = activity.findViewById(android.R.id.content);
然后再把悬浮球View添加进去
View root = activity.findViewById(android.R.id.content);
if (root instanceof FrameLayout) {
FrameLayout content = (FrameLayout) root;
View viewById = content.findViewById(R.id.float_ball_icon);
if (viewById != null) {
return;
}
floatView = View.inflate(gameActivity, R.layout.view_float_ball, null);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ImageView floatBallIcon = floatView.findViewById(R.id.float_ball_icon);
params.gravity = Gravity.START;
params.topMargin = 100;
ValueAnimator animator &#