android-orientation

Android: retaining camera preview on orientation change while other views can rotate

牧云@^-^@ 提交于 2019-12-01 06:47:58
I'm trying to build a custom camera app. I have a class which extends SurfaceView for the camera preview. When the device changes orientation, this surface is destroyed and recreated, leading to a noticeable "glitch" which diminishes user experience. What I'd like to do is to prevent this camera preview from having to be recreated on orientation change. In addition, I'd like to have some buttons overlaying this preview (e.g. flash, choice of front/back camera etc.) which WOULD rotate on orientation change. This is similar to what the stock camera app does: Stock camera in landscape mode. Stock

Keyboard dismissed on rotation to landscape mode Android

∥☆過路亽.° 提交于 2019-12-01 06:27:12
问题 Running into a strange problem. When I'm on portrait and have the keyboard visible and rotate to landscape, the keyboard is dismissed (with or without text in the EditText ). The text is also retained on rotation. When I'm on landscape and have the keyboard visible and rotate to portrait, the keyboard continues to be visible on portrait. Any idea what could be going wrong? I'm not handling configChanges myself and I don't intend to. I also tried using stateUnchanged | adjustResize in the XML

Android: retaining camera preview on orientation change while other views can rotate

吃可爱长大的小学妹 提交于 2019-12-01 04:50:44
问题 I'm trying to build a custom camera app. I have a class which extends SurfaceView for the camera preview. When the device changes orientation, this surface is destroyed and recreated, leading to a noticeable "glitch" which diminishes user experience. What I'd like to do is to prevent this camera preview from having to be recreated on orientation change. In addition, I'd like to have some buttons overlaying this preview (e.g. flash, choice of front/back camera etc.) which WOULD rotate on

Why does onLayout and onSizeChanged get called twice on an orientation change?

吃可爱长大的小学妹 提交于 2019-12-01 03:20:50
I've noticed that onLayout and onSizeChanged get called twice in immediate succession after an orientation change, either from landscape->portrait or from portrait->landscape, when handling the configuration change from an Activity. Furthermore, the first onLayout/onSizeChanged contain the old dimensions (before the rotate), while the 2nd onLayout/onSizeChanged contain the new (correct) dimensions. Does anyone know why, and/or how to work around this? It seems like perhaps the screen size change happens quite some time after the configuration change - i.e., the dimensions are not correct

Simple Android Camera App - Rotation causes NullPointerException

好久不见. 提交于 2019-12-01 01:36:29
I'm new to Android development and was playing around with the camera. I just wanted to create a simple app that would take a photo using the native camera app and give me back the file path of that image. I have that working fine, but I've hit a strange error. When I tap the button to launch the camera, if I change the orientation of the screen while in the camera app, and don't switch back before I exit the camera (pressing the Done button when I'm asked if I want to retake or not), it causes a NullPointerException to be thrown. I'm at a bit of a loss here as to how to figure this one out,

SCREEN_ORIENTATION_LANDSCAPE upside down - Why?

瘦欲@ 提交于 2019-11-30 23:32:16
问题 I am using the following code to set orientation locking per user preference: private void doLock(boolean locked) { if (locked) { int o = getResources().getConfiguration().orientation; if (o == Configuration.ORIENTATION_LANDSCAPE) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); else if (o == Configuration.ORIENTATION_PORTRAIT) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } } It

Handle states of orientation changes

寵の児 提交于 2019-11-30 19:29:58
问题 How can I handle all states of orientation event occurs? Something like: before starting (save some screen states) when happening (animation purposes) after it's happen (load the screen state) I know that onConfigurationChanged can handle orientation changes. And I tried this: public void onConfigurationChanged(Configuration cfg) { saveState(); super.onConfigurationChanged(cfg); loadState(); } On saveState I store the lastIndex viewed on the Gallery on SharedPreferences. On loadState I get

Android Fragments recreated on orientation change

梦想与她 提交于 2019-11-30 07:59:29
问题 I'm developing an app that basically has an ActionBar. When my app starts, the Activity creates the fragments and attaches them to each tab, so when I switch I get different views. The problems arise when I try to rotate the device. After some struggle, I noticed that Android automatically recreates the previously added fragments like this: SummaryFragment.onCreate(Bundle) line: 79 FragmentManagerImpl.moveToState(Fragment, int, int, int) line: 795 FragmentManagerImpl.moveToState(int, int, int

Best Way: Save & Restore TextView Position in ScrollView

好久不见. 提交于 2019-11-30 03:29:43
What i want is, upon the device changes orientation, the top line on the screen when in Portrait remains the top line on screen in Landscape. And vice versa. As the width of the screen is likely to be different between Portrait and Landscape, the line width of the text, which means also the width of the TextView and the ScrollView , will vary. Thus, the line-wrap will be different in different screen configurations (Portrait vs. Landscape, large vs. small). The line-break will be at different position in different cases. There are three not-so-perfect solutions for your reference. Also

Saving Fragment State on Orientation Change

橙三吉。 提交于 2019-11-29 22:06:21
问题 I'm creating a file manager app for Android, and two classes below are the majority of the logic that goes into doing that. What I'm doing is that on startup of the ContentList, it adds the ContentListFragment to the container layout in the ContestList xml. By adding the ContentListFragment, I get the current path, then call setFileDir(String S) that basically gets the File at the passed in path, getting the list of Files at that location, initializing the array, and then initializing the