How can I check if the Android phone is in Landscape or Portrait?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
such this is overlay all phones such as oneplus3
right code as follows:
there are many ways to do this , this piece of code works for me
It's also worth noting that nowadays, there's less good reason to check for explicit orientation with
getResources().getConfiguration().orientation
if you're doing so for layout reasons, as Multi-Window Support introduced in Android 7 / API 24+ could mess with your layouts quite a bit in either orientation. Better to consider using<ConstraintLayout>
, and alternative layouts dependent on available width or height, along with other tricks for determining which layout is being used, e.g. the presence or not of certain Fragments being attached to your Activity.i think using getRotationv() doesn't help because http://developer.android.com/reference/android/view/Display.html#getRotation%28%29 getRotation() Returns the rotation of the screen from its "natural" orientation.
so unless you know the "natural" orientation, rotation is meaningless.
i found an easier way,
please tell me if there is a problem with this someone?