0

I'm developing an Android application based on the Simon Game ( https://en.wikipedia.org/wiki/Simon_(game) ). To represent the buttons of the game (blue, red yellow and green) I drew buttons that I will use in a ImageButton.

Exempl of a button

As you can see, my buttons have a special shape, and the images have no background. I would like that the clickable area matches the shape of the button but it doesn't. It matches a square around my image.

So, my question is, do you know how can i define the clickable area so it matches only the "triangular" shape of my button ?

I already tested this :

<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/btnj"
android:id="@+id/btnImgJaune"
android:background="@null"
android:clickable="false" />`

Thank you.

Lydia
  • 9
  • 4
  • check this http://stackoverflow.com/questions/25396194/creating-a-triangular-shaped-button-for-android-application or this http://stackoverflow.com/questions/25398788/triangular-shaped-button-for-android-activity maybe can help you. – Siloé Bezerra Bispo Mar 23 '17 at 14:55
  • Possible duplicate of [how can creat custom click able shape on a image in android?](http://stackoverflow.com/questions/28499282/how-can-creat-custom-click-able-shape-on-a-image-in-android) – sai Mar 23 '17 at 15:01
  • Thx for your answer. I already checked those topics but my buttons are not perfect triangles, they have a rounded exterior and I don't know how to use the xml proprieties to do that. – Lydia Mar 23 '17 at 15:03
  • There is an image of my triangle in my post – Lydia Mar 29 '17 at 22:57

1 Answers1

0

An Android View has a square shape, so you can't do that. Maybe you can try implementing your own ViewOutlineProvider with a radius Outline.

ChristopheCVB
  • 7,269
  • 1
  • 29
  • 54