小编Ask*_*ion的帖子

六角形按钮,六角形触摸区域

我需要创建相同的按钮,如下图所示.Button必须在里面的文字.

  • 在此输入图像描述

当我在进行XML布局时遇到了Button触摸区问题.每个下一个按钮都覆盖前一个带有矩形Button区域的按钮.

  • 在此输入图像描述

是否像我一样在XML标记中放置六边形,以实现像图片中的六边形?请帮助我解决触摸区域的问题,如果可能的话告诉我如何正确创建布局,因为我不确定,因为我做的是正确的.

这是我的测试布局的一部分:

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_marginTop="?attr/actionBarSize">


            <Button
                android:id="@+id/button1"
                android:layout_width="130dp"
                android:layout_height="134dp"
                android:background="@drawable/hexagon_shape_img"
                android:text="Home page"
                android:textSize="@dimen/small_text" />

            <Button
                android:id="@+id/button2"
                android:layout_width="130dp"
                android:layout_height="134dp"
                android:layout_marginLeft="65dp"
                android:layout_marginTop="-20dp"
                android:background="@drawable/hexagon_shape_img"
                android:text="Tavern"
                android:textSize="@dimen/small_text" />

        </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

xml android button

5
推荐指数
1
解决办法
3243
查看次数

标签 统计

android ×1

button ×1

xml ×1