【问题标题】:Android Hexagon shape button having hexagon touch bounds具有六边形触摸边界的 Android Hexagon 形状按钮
【发布时间】:2015-03-10 14:44:15
【问题描述】:

我想在 android 中创建一个六边形按钮,这样它的触摸区域就不会重叠(在右侧),即。我想要六边形触摸绑定而不是矩形触摸绑定。我尝试使用图像视图,但它不排除透明(以蓝色显示,左)。是否有任何由 xml 形状/路径定义的可点击对象。如果可能的话,任何人都可以向我展示一个按钮的 xml 形状/路径部分或任何其他方法。

【问题讨论】:

    标签: android xml user-interface button


    【解决方案1】:

    查看this

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

    属性:

    • siBorderColor边框颜色
    • siBorderWidth dp 中的边框宽度

    • siBorderAlpha边界的alpha值在0.0-1.0之间

    • siStrokeCap边框笔画帽型对接|圆形|方形
    • siStrokeJoin边框笔画连接类型bevel|miter|round
    • siSquare 将宽度和高度设置为给定值的最小值 真|假
    • siShape 对 SVG 的引用。这是由 ShapeImageView 使用的,而不是 它的子类。

    【讨论】:

      【解决方案2】:

      没有可以为您定制形状的系统视图。您需要创建自定义视图:http://developer.android.com/training/custom-views/index.html 并在其onTouchEvent() 中确定用户的点击是在可点击区域内部还是外部并采取相应措施。

      【讨论】:

        猜你喜欢
        • 2015-03-22
        • 1970-01-01
        • 2013-07-12
        • 1970-01-01
        • 1970-01-01
        • 2014-09-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多