質問編集履歴

1

追記

2017/08/22 07:11

投稿

xoxoo
xoxoo

スコア29

test CHANGED
File without changes
test CHANGED
@@ -53,3 +53,79 @@
53
53
 
54
54
 
55
55
  メソッド findViewById(int) は型 xxxService で未定義です。
56
+
57
+
58
+
59
+ ###
60
+
61
+ ```java
62
+
63
+ @Override
64
+
65
+ public int onStartCommand(Intent intent, int flags, int startId) {
66
+
67
+
68
+
69
+ // inflaterの生成
70
+
71
+ LayoutInflater layoutInflater = LayoutInflater.from(this);
72
+
73
+
74
+
75
+ windowManager = (WindowManager)getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
76
+
77
+ WindowManager.LayoutParams params = new WindowManager.LayoutParams(
78
+
79
+ WindowManager.LayoutParams.MATCH_PARENT,
80
+
81
+ WindowManager.LayoutParams.WRAP_CONTENT,
82
+
83
+ WindowManager.LayoutParams. TYPE_SYSTEM_ERROR,
84
+
85
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
86
+
87
+ | WindowManager.LayoutParams.FLAG_FULLSCREEN
88
+
89
+ | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
90
+
91
+ | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
92
+
93
+ | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
94
+
95
+ // | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
96
+
97
+ | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
98
+
99
+ PixelFormat.TRANSLUCENT);
100
+
101
+
102
+
103
+ // 最下部に配置
104
+
105
+ params.gravity= Gravity.BOTTOM | Gravity.CENTER;
106
+
107
+
108
+
109
+ //params.x = 20 * dpScale; // 20dp
110
+
111
+ // params.y = 100 * dpScale; // 80dp
112
+
113
+
114
+
115
+ // レイアウトファイルからInfalteするViewを作成
116
+
117
+ view = layoutInflater.inflate(R.layout.overlapservice, null);
118
+
119
+
120
+
121
+ // Viewを画面上に追加
122
+
123
+ windowManager.addView(view, params);
124
+
125
+
126
+
127
+
128
+
129
+ ```
130
+
131
+ としていてoverlapserviceのレイアウトファイルにはfindViewByIdしたいViewを記述しています。