Can I use android.widget.ImageButton in Toga? #2087
-
Toga can directly use Android native APIs directly. Now that Toga does not have an ImageButton widget, how can I add an android.widget.ImageButton to Toga.Box? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
I can't point you at a simple worked example, but: if you have an instance of A normal Toga widget would be added to Alternatively, you could define a custom "ImageButton" widget, but only provide an Android implementation. I'd guess that 90% of the implementation would be identical to Toga's Button - the only real difference would be the parts that actually construct the Button, and the parts that direct the factory to construct the Android implementation. |
Beta Was this translation helpful? Give feedback.
-
您好,我已收到来信,会尽快给予你回复。
|
Beta Was this translation helpful? Give feedback.
I can't point you at a simple worked example, but: if you have an instance of
toga.Box()
calledmybox
,mybox._impl.native
is an instance ofandroid.widget.RelativeLayout
, andmybox.container.native_content
is another instance ofandroid.widget.RelativeLayout
that represents the top-level container for the window being laid out. You can then use Chaquopy's APIs to wrap the Java classes needed to construct anandroid.widget.ImageButton
.A normal Toga widget would be added to
mybox.container.native_content
and then have positioning parameters set as part of Toga's layout algorithm; if you were to add a widget to the._impl.native
of a box, that widget should be inserted relative to the posit…