android-orientation

Android Portrait and landscape

五迷三道 提交于 2021-01-28 07:48:54
问题 I locked my app on portrait mode for mobile devices, and landscape for TV. The issue is, I want it on the whole app. I have multiple activities inside my app, so I have to check every activity for portrait and landscape. Is there a way to make my code global for all the activities? I don't want to write that code in every activity. Here is my code: I'm using this before: setContentView(R.layout.activity_main); MainActivity.java // locking out landscape screen orientation for mobiles if

How to handle orientation change using fragment?

心不动则不痛 提交于 2020-02-21 13:18:45
问题 I now have 2 fragment, one fragment handle portrait mode then another handle landscape mode. But the problem is that when rotate from portrait to landscape then back to portrait. It will not show the same thing that show on the first portrait mode. Is there any code that can solve this problem? This code is inside the fragment holder: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.frag_holder); FragmentManager fm =

Inverted width and height when unlocking with device rotated

允我心安 提交于 2020-01-25 09:20:29
问题 I'm getting screen size using this code: getWindowManager().getDefaultDisplay().getRealSize(size); sw = size.x; sh = size.y; I'm using it for specifying DialogFragment width and height: @Override public void onResume() { super.onResume(); int sw = Util.getInstance().getScreenWidth(getActivity()); int sh = Util.getInstance().getScreenHeight(getActivity()); getDialog().getWindow().setLayout((int)(sw*0.6), (int)(sh*0.6)); } *I need to specify the width and height of the dialog in onResume. It's

Android Orientation Change: Different Layout, Same Fragments

∥☆過路亽.° 提交于 2020-01-23 06:11:11
问题 This is pretty much a classic Android use case. Say we have 2 fragments: FragmentA and FragmentB. In landscape mode, FragmentA and FragmentB sit side by side. In portrait mode, they each take up the full screen when in use. (See this image but replace tablet->landscape and handset->portrait) As explained here (Supporting Single-Pane and Multi-Pane Layouts), there are 2 ways to achieve this: 1- Multiple fragments, one activity: Use one activity regardless of the device size, but decide at

Activity rotating itself and back to normal in android 8.1

放肆的年华 提交于 2020-01-12 07:20:12
问题 My App is running fine for all the android version but I have noticed that in Android 8.1.0 (Oreo) when I go the screen from portrait activity to landscape activity and when I press back button it shows the abnormal behavior. Screen auto rotate from landscape and returns it to normal. It looks like Activity is restarting itself. Below are the activities which is define in the manifest file. <activity android:name=".Home.TrainingsActivity" android:configChanges="keyboardHidden|orientation

VideoView & Fullscreen & Orientation changes - Android

让人想犯罪 __ 提交于 2020-01-11 05:08:57
问题 I implemented a e-Reader that has embedded video players on it, I need a option to toggle fullscreen mode from the player. My question is the following: Which is the best way to play a video on fullscreen and let the user come back from this state to the page he is reading before and also keep the current time of the video. Another complicated situation I need to handle is: There's different visualizations of a page on portrait and landscape, if the user toggle fullscreen on portrait and

DialogFragment disappears after device rotation despite applying common fixes

烈酒焚心 提交于 2020-01-06 13:49:06
问题 I have a DialogFragment that I launch when a user taps a menu item on the ActionBar. Everything about the Dialog functions properly - it launches just fine and it does everything I've set it up to do. Unfortunately, as soon as I rotate my device, the DialogFragment disappears. This seemed to be a common problem back in 2012 - I've scoured StackOverflow and tried all of the common fixes that have been posted in the last couple of years. This SO post in particular summarizes all of the

Video plays upside down when recorded from Front Camera in Android

 ̄綄美尐妖づ 提交于 2020-01-05 18:06:23
问题 I am doing android Video Camera Application. It should have capability of recording with back and front camera. I am done with back camera and everything is fine. But when I record with front camera, video plays upside down. I have to play the videos recorded in my application itself. I am using VideoView, How to set orientation or make it play correctly?. Video when played in default media player also playing upside down. Tried sending the video to iPhone and checked but still it plays

Programmatically resizing EditText on orientation change

旧时模样 提交于 2020-01-05 08:21:55
问题 I'm trying to programmatically resize an EditText when the orientation of the phone changes, here's what I have so far: private final float editTextWidthLandscap = 380; private final float editTextWidthPortrait = 220; @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); Resources r = getResources(); float px; if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP