Hexagon Android Hexagon Button

I want to create a hexagon shape button in android to touch the area does not overlap (right), i.e. I want the heaxagon to touch a non-rectangle touch. I tried using the image, but that does not exclude tranparent (shown in blue, on the left). Is there any clickable object that is defined by xml shape / path. please, anyone can show me the xml shape / path part for just one button, if possible or any other method. enter image description here

+6
source share
2 answers

check this

enter image description here

<com.github.siyamed.shapeimageview.{ClassName} android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="8dp" android:src="@drawable/neo" app:siBorderWidth="8dp" app:siBorderColor="@color/darkgray"/> 

Properties:

  • siBorderColor border color
  • siBorderWidth border width in dp

  • siBorderAlpha Alpha border value between 0.0-1.0

  • siStrokeCap border stroke cap type butt | round | square
  • siStrokeJoin border stroke join type bevel | miter | round
  • siSquare set the width and height to a minimum of the set values ​​true | Lying
  • siShape link to SVG. It is used by ShapeImageView, not subclasses of it.
+2
source

There is no system view that custom forms will do for you. You need to create a custom view: http://developer.android.com/training/custom-views/index.html and in onTouchEvent() determine whether the user is within or outside the area accessible for clicks and act accordingly.

+1
source

Source: https://habr.com/ru/post/980883/


All Articles