Search code examples
androidandroid-layoutandroid-notificationsaction-button

Android notification action button position


Currently in Android, the notification action button appears by default as right aligned to the screen. I am showing two action buttons in my app and they're shown right aligned by default.

Can we alter the position of the action buttons as I want them center aligned?


Solution

  • You won't be able to pick how the default actions are displayed (besides customizing the text and icons) but you can instead implement a completely custom view for your Notification.

    See setCustomView() which lets you pass a RemoteViews object that can be inflated from your own layout. You can define any type of buttons that you want and align them in your own desired way. You will just have to set a click listener on the specific views for those buttons within your RemoteViews to launch your PendingIntent when the buttons are clicked.