Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override the screenOrientation property of an activity which is in library

The title of this question is not exactly reflects my question I have trimmed it because it went too lengthy. Sorry for my bad English too.

Okay,

I am using a library which has an activity, I am using that activity in my app. The orientation of that activity is working fine in tablets i.e., both landscape and portrait but in phones it sticks to portrait mode.

When I have seen the Manifest file of that library its like

<activity
   android:name="DrawingActivity"
   android:configChanges="orientation|keyboardHidden|screenSize"
   android:finishOnTaskLaunch="true"
   android:screenOrientation="unspecified">

In the thread Android Orentation Changes. I came to know it should like android:screenOrientation="fullSensor" to work.

Now I am trying to override the screenOrientation property of the activity as said here

using tools:replace attribute but still its not working. Please can anybody help me to solve this issue.

This is how I'm trying to achieve.

<activity
   android:name="DrawingActivity"
   android:configChanges="orientation|keyboardHidden|screenSize"
   android:finishOnTaskLaunch="true"
   android:screenOrientation="fullSensor"
   tools:replace="android:screenOrientation">

If my question is not clear/too broad please let me know I'll edit my question.

Regards

like image 833
ImGenie Avatar asked Oct 16 '25 17:10

ImGenie


1 Answers

You can use tools:node="merge", for example:

<activity android:name="DrawingActivity"
    android:screenOrientation="fullSensor"
    tools:node="merge">
</activity>

this node will be merged with the existing one and overrides any duplicates.

for more details about this refer to https://developer.android.com/studio/build/manifest-merge#node_markers

like image 153
Mohammad Ersan Avatar answered Oct 18 '25 18:10

Mohammad Ersan