Answer the question
In order to leave comments, you need to log in
How to make a round button in android?
We need a round button with ! round clickable area.
The round background is clear how it is done, but the button itself remains square, that is, when you click on the corners (where there is no background), the click is still processed.
On the picture:
How to make sure that clicks on the red area are not processed?
Answer the question
In order to leave comments, you need to log in
создаем в папке drawable файл oval_button.xml
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="#FCD366"/>
</shape>
</item>
</selector>
а в активити:
<Button
android:id="@+id/button1"
android:background="@drawable/oval_button"/>
Whether you like it or not, any View is drawn on a Canvas , which is uniquely rectangular in shape. Only a custom View is suitable for your task, in the onDraw method of which you draw a round button, and in the onKeyDown method you calculate the coordinates and decide whether the event should be processed or not, initiating an additional performClick to call subscriber handlers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question