我将图像视图添加到线性布局,然后将该线性布局添加到滚动视图。我正在使用窗口管理器显示滚动视图,因为这一切都发生在服务中。我可以看到滚动条,当我上下拖动时,滚动条会移动,但图像视图不会。
这是我的代码:
// define the two views
scroll = new ScrollView(this);
trayAppList = new LinearLayout(this);
//define basic layout properties
trayAppList.setOrientation(LinearLayout.VERTICAL);
width = 50;
height = display.getHeight();
// shortcut list container
lstParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, PixelFormat.TRANSLUCENT);
lstParams.gravity = dockLocation;
scroll.setLayoutParams(new android.view.ViewGroup.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, height));
//define window manager
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
//now display views
scroll.setScrollContainer(true);
scroll.addView(trayAppList);
wm.addView(scroll, lstParams);