If you add your fragment to your activity programmatically, you can check to see if your picture is landscape or portrait, and then launch whichever fragment you'd like. See the documentation here:
http://developer.android.com/guide/components/fragments.html#Adding
Your code will look something like this
FragmentManager fragmentManager = getFragmentManager()
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
if (landscapeImage) {
LanscapeFragment fragment = new LandscapeFragment();
fragmentTransaction.add(R.id.fragment_container, fragment);
} else {
PortraitFragment fragment = new PortraitFragment();
fragmentTransaction.add(R.id.fragment_container, fragment);
}
fragmentTransaction.commit();
In order to determine whether your image is landscape
or portrait
- by which I assume you mean whether the image is wider than it is tall or not, you could load the image into a bitmap, and check its width vs its height.
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.my_image);
boolean landscape = bm.getWidth() > bm.getHeight();