我尝试使用FrameLayout将SurfaceView放在RecyclerView的顶部(哇是标题:D)。但即使我在SurfaceView中根本不绘制,屏幕也会变黑,我根本看不到RecyclerView。
我的MainActivity中的三个初始化:
我的表面视图:
surfaceView = new SurView(this, screenX, screenY);
我的RecyclerView:
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
for (int i = 0; i < 100; i++) {
input.add("Test" + i);
}
mAdapter = new RealFarmAdapter(input);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(mAdapter);
if (recyclerView != null) {
ViewGroup parent = (ViewGroup) recyclerView.getParent();
if (parent != null) {
parent.removeView(recyclerView);
}
}
我的FrameLayout:
FrameLayout frameLayout = new FrameLayout(this);
frameLayout.addView(recyclerView, 0);
frameLayout.addView(surfaceView, 1);