android商城购物车悬浮多个页面之上怎么实现
答案:1 悬赏:0 手机版
解决时间 2021-12-25 05:35
- 提问者网友:川水往事
- 2021-12-24 21:45
android商城购物车悬浮多个页面之上怎么实现
最佳答案
- 五星知识达人网友:煞尾
- 2021-12-24 22:06
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager wm = (WindowManager) getApplicationContext()
.getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
// 悬浮所有页面之上
lp.type = WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
// 失去焦点
lp.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
| LayoutParams.FLAG_NOT_FOCUSABLE;
TextView tv = new TextView(this);
tv.setText("我是不是你最疼爱的人,你为什么不说话,握住是你冰冷的手动也不动让我好难过");
tv.setBackgroundColor(Color.WHITE);
wm.addView(tv, lp);
}
}
import android.graphics.Color;
import android.os.Bundle;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager wm = (WindowManager) getApplicationContext()
.getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
// 悬浮所有页面之上
lp.type = WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
// 失去焦点
lp.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
| LayoutParams.FLAG_NOT_FOCUSABLE;
TextView tv = new TextView(this);
tv.setText("我是不是你最疼爱的人,你为什么不说话,握住是你冰冷的手动也不动让我好难过");
tv.setBackgroundColor(Color.WHITE);
wm.addView(tv, lp);
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯