How in Android the buttons with complex shape can be done?
For example, take a look at this joystick
Look at each button individually and use a layout (such as a FrameLayout
or RelativeLayout
) to try and fit the pieces together. Start by making a ToggleButton
and using a drawable background (`android:background="@drawable/button_background") to give it the look of one piece of the button. Do this and align all four buttons in the shape you'd like, then put place another layout behind them (with a background drawable) do complete the final piece, giving the buttons a container that makes it appear as one solid element for users.
I'm not entirely sure how you would work with the touch radius of each button... I suggest you look up other examples that work with 'odd' button shapes to hack together a working solution.
I hope this points you in the right direction.
The real solution is to create own view to correctly handle such type of shapes. Custom views discussed here: https://developer.android.com/training/custom-views/index.html - you can also find some other sources on the net.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.