Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18040] Android: Expose "gravity" constants in Ti.UI.Notification

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2016-04-25T09:07:43.000+0000
Affected Version/sRelease 3.4.0
Fix Version/sRelease 5.4.0
ComponentsAndroid
LabelsTCSupport, gravity, notification, toast
ReporterFokke Zandbergen
AssigneeHans Knöchel
Created2014-11-10T16:42:57.000+0000
Updated2016-07-01T00:35:51.000+0000

Description

I'd like to position an Android Toast (Ti.UI.Notification on the top half of the screen. I thought this wasn't possible, but then found that the first [gravity](http://developer.android.com/guide/topics/ui/notifiers/toasts.html#Positioning) argument for setGravity that I needed is actually [exposed](https://github.com/appcelerator/titanium_mobile/blob/58198c641d77e17d156431666e80bae732b5c130/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUINotification.java#L65-L69), just not documented. Using the integer value of the Android documentation for [Gravity.TOP](http://developer.android.com/reference/android/view/Gravity.html#TOP) I was able to position the Toast on the top half of the screen:
Ti.UI.createNotification({
    message: "Please Stand By",
    duration: Ti.UI.NOTIFICATION_DURATION_LONG,
    gravity: 48 // Gravity.TOP
}).show();
My request is: * Document the gravity property * Expose the gravity constants (Ti.UI.Android.GRAVITY_TOP etc..)

Comments

  1. Hans Knöchel 2016-04-25

    Community PR: https://github.com/appcelerator/titanium_mobile/pull/6435 Demo:
       Ti.UI.createNotification({
           message: "Please Stand By",
           duration: Ti.UI.NOTIFICATION_DURATION_LONG,
           gravity: Ti.UI.Android.GRAVITY_TOP
       }).show();
       
  2. Lokesh Choudhary 2016-07-01

    Verified the implementation. Closing. Environment: Appc Studio : 4.7.0.201606220541 Ti SDK : 5.4.0.v20160630074247 Ti CLI : 5.0.9 Alloy : 1.9.0 MAC El Capitan : 10.11.5 Appc NPM : 4.2.7-2 Appc CLI : 5.4.0-23 Node: 4.4.4 Nexus 6 - Android 6.0.1

JSON Source