Reputation: 1548
I am working with OpenCV in android. I am forced to use
android:screenOrientation="landscape"
in my AndroidManifest.xml
The problem I am facing is that I want to rotate only one Button according to screen orientation. The rest must remain un rotated.
Is that possible?
Will the line I added to Manifest File prevent detection of all future rotations?
Upvotes: 1
Views: 92
Reputation: 9121
you need to provide layout for that.
for Example.
res
layout
main.xml
layout-land
main.xml
Now create your layout you want under -land
folder. And it will load when phone is rotate.
Feel free to ask anything.
Upvotes: 1
Reputation: 261
Yes the line added prevent all rotations.
You can create a new folder under /res , called 'layout-land' (without quotes), copy your layout to these folder and modify. Android read layout folder to protait orientation, and layout-land to show the layout landscape orientation.
Upvotes: 2
Reputation: 1036
You can leverage the Position Sensor as described in this article (Position Sensor) to determine the orientation of your phone.
With that, you can get the angle in onSensorChanged() as following.
@Override
public void onSensorChanged(SensorEvent event) {
float azimuth_angle = event.values[0];
float pitch_angle = event.values[1];
float roll_angle = event.values[2];
// Do something with these orientation angles.
}
Hope this helps.
Upvotes: 1