【发布时间】:2014-12-10 06:35:52
【问题描述】:
您好,我正在寻找在 Android 中制作 UI,我正在考虑将四个圆形按钮以菱形的形式彼此靠近。所以我不能将它们包含在正方形网格中,否则它们会在点击时相互重叠。
谁能给我指出一个具有不规则形状(非方形)按钮的教程或示例代码?
【问题讨论】:
-
我知道这很旧,但找到解决方案了吗?我也有类似的问题:stackoverflow.com/questions/27367068/…
您好,我正在寻找在 Android 中制作 UI,我正在考虑将四个圆形按钮以菱形的形式彼此靠近。所以我不能将它们包含在正方形网格中,否则它们会在点击时相互重叠。
谁能给我指出一个具有不规则形状(非方形)按钮的教程或示例代码?
【问题讨论】:
TableLayout 只是为了保持按钮。使用 TableLayout 作为容器来包装您的按钮。然后将 TableLayout 锚定在您想要按钮组的位置。
PSUEDOCODE
<TableLayout
android:id="@+id/ButtonContainer"
android:layout_width="3XButtonWidth"
android:layout_height="3XButtonHeight"
android:layout_alignParentBottom="OrWhereYouNeedIt"
android:layout_alignParentRight="OrWhereYouNeedIt"
>
<TableRow
android:id="@+id/FirstRow">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageButton
android:id="@+/TopButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:AnyOtherParams="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:id="@+id/MiddleRow">
<ImageButton
android:id="@+/LeftButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:AnyOtherParams="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageButton
android:id="@+/RightButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:AnyOtherParams="true"/>
</TableRow>
<TableRow
android:id="@+id/LastRow">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageButton
android:id="@+/BottomButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:AnyOtherParams="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
【讨论】: