[問題] 讓Widget顯示在所有Activity之上
我寫了個app,會在啟動時創造一些widget永遠呈現在所有Activity之上,當切換到其他
app時也會顯示,Service由這些widget啟動與提供參數,我隨時可以按他們。
目前有了一些button,他們都可以正常呈現與運作,code如下:
Display display = getWindowManager().getDefaultDisplay();
_floatStartButtonView = new Button(getApplicationContext());
_wm = (WindowManager) getApplicationContext().getSystemService("window");
WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams();
wmParams.gravity = Gravity.TOP | Gravity.LEFT;
wmParams.x = 0 + display.getWidth() / 8;
wmParams.y = display.getHeight() / 8;
// 2002 = TYPE_PHONE
wmParams.type = 2002;
wmParams.format = 1;
// 40 = default(32)+ FLAG_NOT_FOCUSABLE(8)
wmParams.flags = 40;
wmParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
_wm.addView(_floatStopButtonView, wmParams);
現在由於有一系列的功能button太多,我想用HorizontalScrollView呈現,按個按鈕後出
現在畫面最上方,讓使用者可以左右拉。
LayoutParams的code幾乎跟上面一模一樣,現在view是出來了,卻不能正常運作。
1. 我不能左右滑動她,滑動了也只是像一張固定的圖片一樣不動。
2. 雖然view不能左右滑動,底下卻會出現scroll bar顯示我有在滑,右滑到一定程度
scroll bar就會跑到畫面外不見了。
我試著在activity_main.xml中拉個測試用的HorizontalScrollView,讓她接跟上述的
HorizontalScrollView一樣的資料,結果她可以正常動作,顯示資料是沒問題的,問題在
HorizontalScrollView的設定。
所以我是在type, format還是flags上設定錯了嗎?還是哪裡有問題呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.25.158.213
→
09/25 13:26, , 1F
09/25 13:26, 1F
→
09/25 13:26, , 2F
09/25 13:26, 2F
→
10/07 23:29, , 3F
10/07 23:29, 3F
→
10/07 23:30, , 4F
10/07 23:30, 4F