Android App - How to Set OpenFeint Notification Position
I've Integrated OpenFeint in my开发者_运维技巧 android game but the score-post and achievement unlock notification is shown at bottom of the screen automatically.
how can i manually set the location of the that notification on my screen.? I want to show it to the top of the screen.
The OpenFeint sample code uses the Toast Class to display those notifications. You can easily adjust that code to almost anything you want.
edit: I realize that you might mean the notification that comes from the bottom, in which case you will need to write a class extending com.openfeint.api.Notification.Delegate
and display your own design. Unfortunately OpenFeint doesnt provide parameters on the default notification class.
You can easily show it at the top of the screen by editing the NotificationBase.java file. It is located in com.openfeint.internal.notifications. Just look for the showToast() method, and edit it. Change Gravity.BOTTOM to Gravity.TOP. Check it out below:
protected void showToast() {
OpenFeintInternal.getInstance().runOnUiThread(new Runnable() {
@Override
public void run() {
Context appContext = OpenFeintInternal.getInstance().getContext();
toast = new Toast(appContext);
toast.setGravity(Gravity.TOP, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(displayView);
toast.show();
}
});
}
精彩评论