我想让我的滑块始终位于顶部。 - 已经完成了。 但我不能让他动起来。我应该做些什么改变?
public class SliderOnTop extends Service {
private SeekBar seekBar;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
PixelFormat.TRANSLUCENT);
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
RelativeLayout layout = new RelativeLayout(this);
layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
seekBar = new SeekBar(this);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, 45);
lp.bottomMargin = 0;
lp.leftMargin = 0;
layout.addView(seekBar, lp);
wm.addView(layout, params);
}
}
答案 0 :(得分:1)
您可以在onTouch
上收听View
个事件,然后相应地更改边距。