3
我认为标题覆盖了它:)我有一个可绘制对象,用于获取我可以用手势操纵的.png照片。我也有一个背景图像的xml布局,应该在这个可绘制对象后面。一切都发生在一个片段中。在Android片段中的布局视图中放置可绘制对象
当我运行代码并得到这个片段时,显示png和手势工作,但是,没有膨胀的布局和后退按钮按应用程序崩溃(我猜这是因为我在使用setContentView片段,所以没有后退堆栈?我如何避免这种情况?)。
稍后我会将其他图层添加到场景中。
我的问题是,我怎样才能用xml布局膨胀片段,在它上面显示drawable,以及以后可以在所有上面添加其他视图?
代码是这样对该片段:
public class RoomFragment extends Fragment {
ViewGroup mRoot;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mRoot = (ViewGroup) inflater.inflate(R.layout.room_fragment, null);
/** Placing furniture .png element in SandboxView */
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.furniture);
View view = new SandboxView(this.getActivity(), bitmap);
this.getActivity().setContentView(view); // Replace with inflater?
return mRoot;
}}
谢谢!