Skip to content

How to prevent overlapping of things inside RemoteViews? #13

@alokbhaisahu

Description

@alokbhaisahu

Problem

When I try to add more than one item (like Button and TextView together) in a RemoteView (for widget or custom notification) they superimpose each other.

Expection

Normally, I would want the items added inside RemoteViews to not overlap each other, like what happens in a Activity

What I tried

  • Adding a FrameLayout as a common parent of other items doesn't solve the problem, I tried to nested FrameLayouts inside FrameLayouts but that also didn't solve it.
  • Adding lots of padding makes the items underneath visible, but for buttons that is still a problem, they occupy all the padding space too and it isn't possible to click through the padded space to click the buttons underneath the padded button
  • Adding a LinearLayout hangs the script at the line where it is added

Sample code

import termuxgui as tg


def main():
    with tg.Connection() as c:
    
        # Create custom layout for notification
        rv = tg.RemoteViews(c)

        bt1 = rv.addButton()
        rv.setText(bt1, "button1")

        bt2 = rv.addButton()
        rv.setText(bt2, "button2")
        

        # Create a notification
        notif = tg.Notification(c, "test", 3)
        notif.setlayout(rv)
        notif.notify()
    
        input()  # To prevent the notification from going away
        exit()
    
    return


if __name__ == "__main__":
    main()

The result: button2 overlaps button1

Version info

  • termux:gui app version 0.1.6
  • output of termuxgui.Connection.getversion() : 7
  • termux app version 0.118.0+57e4ef4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions