android-orientation

Android emulator camera - webcam orientation

有些话、适合烂在心里 提交于 2019-12-04 06:17:52
I am using my Mac webcam to simulate an Android front-camera in the emulator. Unfortunately the camera seems in landscape orientation - screenshot , even though the emulator is in portrait one. Note that the camera behaves properly on a real device (i.e. it has a portrait orientation). My Emulator configuration: Nexus 5X, Android Nougat 7.1.1, API Level 25, Startup Orientation: portrait, front-camera: webcam0, back-camera: Emulated How can I use the webcam with proper orientation? Ultimately I solved this by detecting if I'm running in an emulator: public static boolean isEmulator() { return

Disable and enable orientation changes in an activity in Android programatically

a 夏天 提交于 2019-12-04 03:35:09
I have an App that make some background staff. When the background work is running a progress Circle is shown, if the device is rotated during this time then the Activity is "reset" and I want to avoid that. For this reason I decided disable orientation during this process. I have seen differends threads for this question but none with a valid solution, at least in my case. The solutions posted are about fixing the activity orientation but you have to deal with the fact that the REVERSE orientations are not returned if you use: getResources().getConfiguration().orientation The function above

Simple Android Camera App - Rotation causes NullPointerException

前提是你 提交于 2019-12-03 23:05:07
问题 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

Android: How to save custom finger paint view on orientation change

淺唱寂寞╮ 提交于 2019-12-03 17:12:12
I'm trying to create a custom view where a user can draw their signature. One where you can put it into the view programmatically and set the size, etc. I haven't had to do this before so I based it off the fingerpaint class from android api demos. Problem right now is that it erases the object on orientation change and I'm not sure how to get it to not do that. The code for PaintView private Bitmap mBitmap; private Canvas mCanvas; private Path mPath; private Paint mBitmapPaint; private boolean mDrawPoint; private int stateToSave; private Paint mPaint; public PaintView(Context context) { super

How to lock fragment orientation without locking activity orientation?

落爺英雄遲暮 提交于 2019-12-03 16:36:56
问题 I have a specific use case where I want a fragment to be locked in portrait mode, but still rotate the activity (and/or other fragments visible in the same activity). Is it possible to do that? All the solutions to locking a fragment orientation suggest to use setRequestedOrientation and lock the activity orientation, but I need other visible fragments to rotate. My app supports API 10+ (if there is a nice solution that uses API 11+ I may consider removing support for landscape in API <11).

Redraw multiple Paths at same positions from previous layout orientation

大城市里の小女人 提交于 2019-12-03 13:10:01
Based on my previous question of " How to create a BottomBar as StickyBottomCaptureLayout in camera2 Android api? ", I created a layout with a StickyBar (SB) which is always locked above/near the system bar. I set the default positions and coordinates of the SB and the other layout in onLayout() (exactly as my answer ). The upper layout is a simple custom DrawView which has an ArrayList of Path s drew by the user. When the device rotates, it recalls onDraw() and calls several times canvas.drawPath() . However, the Path s are redrew with the same coordinates as before but on a different

Retaining list in list fragment on orientation change

时间秒杀一切 提交于 2019-12-03 05:50:56
问题 I have an app using fragments, all of which are contained in a single activity. The activity starts with a fragment containing a menu of buttons, all of which cause various listfragments to replace the original button/menu fragment. My problem is that upon an orientation change, if the activity is displaying one of the listviews, it goes away and the button menu returns. I understand why this is happening... the activity is destroyed and re-created, but not how to work around it and maintain

How to fix layout orientation to vertical?

对着背影说爱祢 提交于 2019-12-03 04:02:17
问题 How to fix layout orientation to portrait and do not allow changing from portrait to landscape during run time? 回答1: In your AndroidMainfest.xml file find the tags of the activities you wish to lock to a given rotation, and add this attribute: android:screenOrientation="portrait" 回答2: Use setRequestedOrientation() as shown: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setRequestedOrientation(ActivityInfo.SCREEN

Changing number of columns with GridLayoutManager and RecyclerView

北城以北 提交于 2019-12-03 01:28:37
问题 Inside my fragment I'm setting my GridLayout in the following way: mRecycler.setLayoutManager(new GridLayoutManager(rootView.getContext(), 2)); So, I just want to change that 2 for a 4 when the user rotates the phone/tablet. I've read about onConfigurationChanged and I tried to make it work for my case, but it isn't going in the right way. When I rotate my phone, the app crashes... Could you tell me how to solve this issue? Here is my approach to find the solution, which is not working

Retaining list in list fragment on orientation change

☆樱花仙子☆ 提交于 2019-12-02 19:13:34
I have an app using fragments, all of which are contained in a single activity. The activity starts with a fragment containing a menu of buttons, all of which cause various listfragments to replace the original button/menu fragment. My problem is that upon an orientation change, if the activity is displaying one of the listviews, it goes away and the button menu returns. I understand why this is happening... the activity is destroyed and re-created, but not how to work around it and maintain the list view/current fragment through the orientation change. I've found setRetainInstance and the