tareksander / termux-gui-python-bindings

A Python library to interact with the Termux:GUI plugin
https://tareksander.github.io/termux-gui-python-bindings/index.html
Mozilla Public License 2.0
94 stars 7 forks source link

How to prevent overlapping of things inside RemoteViews? #13

Open alokbhaisahu opened 2 months ago

alokbhaisahu commented 2 months ago

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

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

tareksander commented 2 months ago

LinearLayout is currently broken in RemoteViews for some reason, and the whole system is due for a rewrite anyways. Currently there is no way.