In my Application I make the images clickable, and once they are clicked another Dialogue type Activity is launched which contains a larger version of the image. The problem is that the Paused activity in the back flashes black whenever the orientation is changed. It seems like it isnt animating its orientation change. Only the Paused Activity flashes black.
Here is the code for the running Activity.
public class ImageDialog extends Activity {
private ImageView mDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.image_dialog);
mDialog = (ImageView)findViewById(R.id.imageView2);
boolean tabletSize = getResources().getBoolean(R.bool.isTablet);
if (tabletSize) {
// do something
} else {
int orientationMode = getResources().getConfiguration().orientation;
if (orientationMode == 1) {
changeViewPlease();
}
}
}
public void onScreenClickClose(View view) {
finish();
}
public void changeViewPlease() {
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
}
and the style being used:
<style name="myDialogTheme" parent="@android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFrame">@null</item>
<item name="android:background">@android:color/transparent</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">.8</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowFullscreen">true</item>
</style>
the layout xml sheet:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/image_dialog_root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:onClick="onScreenClickClose" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="@drawable/image1largerotated" />
</FrameLayout>
Thanks everyone!
This may happens because your background activity is destroyed and recreated again when orientation is changed. This is default behavior of an activity.
You can try this by avoiding recreation of background activity by handling
android:configChanges="orientation"in AndroidManifest of your background activity tag.You can give a try to this too.