2016-11-16 263 views
0

我嘗試添加搜索欄,TimePicker和幾個按鈕,窗口管理器,這樣就不會有任何黃色背景或按上或拖動它,這樣 enter image description here窗口管理問題

後循環圖片是否有可能? 我的代碼:

view = LayoutInflater.from(this).inflate(R.layout.edit_or_new,null); 
     Button button = (Button) view.findViewById(R.id.button6); 
     button.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       stopSelf(); 
      } 
     }); 
     SeekBar seekBar = (SeekBar) view.findViewById(R.id.seekBar); 
     seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 
      @Override 
      public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 
       Log.e("Point_1","onProgressChanged"); 
      } 

      @Override 
      public void onStartTrackingTouch(SeekBar seekBar) { 

      } 

      @Override 
      public void onStopTrackingTouch(SeekBar seekBar) { 

      } 
     }); 
     WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); 
     layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE; 
     layoutParams.flags = WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; 
     windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); 
     windowManager.addView(view, layoutParams); 

謝謝。

回答

0

這是因爲「主題」 呼叫windowManager.addView(view, layoutParams);

setTheme(R.style.AppTheme); 

之前加入這行到你的代碼,如果你沒有任何的主題在你的style.xml補充一點:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <item name="colorPrimary">#3F51B5</item> 
    <item name="colorPrimaryDark">#303F9F</item> 
    <item name="colorAccent">#FF4081</item> 
</style> 
+0

這不幸的是,沒有工作。可能有另一種方法使其正常嗎?此外,我將該視圖添加到WindowManager in Service中。 – Steve

+0

嘗試移動'setTheme(R.style.AppTheme);'到onCreate()方法,並將'WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH'改爲'WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE' –

-1
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); 
layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE; 
layoutParams.flags = 262184; 
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); 
windowManager.addView(view, layoutParams); 
+0

您應該詳細說明您的答案:什麼是什麼,爲什麼這個工作,等 – Zoe

+0

smuth滾動也只能替換windowManager中的代碼 –