Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Hexagon shape button having hexagon touch bounds

I want to create a hexagon shape button in android so that it's touch area does not overlaps (on the right) ie.I want heaxagon touch bound not a rectangle touch bound. I tried to use image view but it does not excludes tranparent(shown in blue, left). Is there any clickable object which is defined by xml shape/path. please can anyone show me xml shape/path part for just one button if its possible or any other method.enter image description here

like image 956
user1476394 Avatar asked Jan 12 '15 18:01

user1476394


2 Answers

check out 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"/>

Attributes:

  • siBorderColor border color
  • siBorderWidth border width in dp

  • siBorderAlpha alpha value of the border between 0.0-1.0

  • siStrokeCap border stroke cap type butt|round|square
  • siStrokeJoin border stroke join type bevel|miter|round
  • siSquare set width and height to the minimum of the given values true|false
  • siShape a reference to an SVG. This is used by ShapeImageView, not the subclasses of it.
like image 150
Steve Avatar answered Nov 16 '22 23:11

Steve


There's no system view that would do custom shapes for you. You need to create custom view: http://developer.android.com/training/custom-views/index.html and in its onTouchEvent() determine if user's tap is inside or outside clickable area and act accordingly.

like image 21
Marcin Orlowski Avatar answered Nov 17 '22 00:11

Marcin Orlowski