我在 DialpadFragment 中创建了它,但是当 MO 调用进行时,InCallScreen 总是会覆盖我的按钮。这是我的代码:
private void createStopButton() {
if (mstopButton == null) {
mstopButton = new Button(mActivity);
mstopButton.setText("Stop Dial");
}
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY|
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
PixelFormat.OPAQUE);
params.gravity = Gravity.CENTER | Gravity.TOP;
final WindowManager wm = (WindowManager)mActivity.getSystemService(Context.WINDOW_SERVICE);
mstopButton.setOnClickListener( new View.OnClickListener() {
public void onClick(View view) {
mIsRedialStatus = false;
wm.removeView(mstopButton);
}
});
wm.addView(mstopButton, params);
}
任何人都可以帮助解决如何将我的按钮带到屏幕顶部。我在互联网上调查了很多代码,我发现他们将顶层相关代码放在服务中。我还应该通过服务实现它吗?非常感谢!