I think the title covers it :) I have a drawable object that fetches .png photo which I can manipulate with gestures. I also have a xml layout with a background image that is supposed to be behind this drawable object. Everything happens in a fragment.
When I run the code and get to this fragment, png is displayed and gestures work, BUT, there is no inflated layout and on back button press app crashes (I'm guessing that is because I'm using setContentView in fragment so there is no back stack? How do I avoid this?).
Later on I will add other layers to the scene.
My question is, how can I both inflate the fragment with xml layout, display drawable on top of it, and maybe later on add other views on top of all that?
Code goes like this for this fragment:
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;
}}
Thank you!