Question

I am coding an Android game in which 2 players play at the same time. Player 1 faces the phone in a normal way and Player 2 faces it upside down. Each player can change preferences which I want to be accessed through a popup menu which will be anchored to an onscreen Button. Each player will have their own Button.

I have managed to rotate the widgets for Player 2 by adding the following xml tags in the layout resources:

android:rotation="180"

So that part is all well.

My question is, how do I go about making an android.widget.PopupMenu also appear upside down for Player 2? The effect I am looking for is that Player 2 will get a PopupMenu which they would be able to read from their angle.

Any help or suggestions on how to best achieve this will be much appreciated.

Was it helpful?

Solution

I solved a similar issue by using PopupWindow. PopupWindow can be constructed with any layout of your choosing, such as one you inflate from xml. That layout can have the android:rotation tags.

In my case I used

new PopupWindow(popupContent, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

where popupContent is the layout I inflated from xml.

PopupWindow docs: http://developer.android.com/reference/android/widget/PopupWindow.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top