Android 菱形按钮布局

标签 android android-layout user-interface

我目前正在使用 android studio 开发示例应用程序。我需要设计菱形按钮并按如下方式查看它们(附截图)。但我不知道如何用 android 制作这种东西。


有四个菱形按钮,它们按照以下屏幕截图对齐。


截图:

Android Button Layout

最佳答案

这是根据设备调整边距的示例代码,您可以使用 imageView 而不是按钮

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
    <LinearLayout
        android:id="@+id/firstRow"
        android:rotation="-30"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp"
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:text="Button 2"
            android:id="@+id/button2" />
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:text="Button 1"
            android:id="@+id/button1"/>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/secondRow"
        android:layout_below="@+id/firstRow"
        android:rotation="-30"
        android:layout_marginTop="24dp"
        android:layout_marginLeft="68dp"
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:text="Button 4"
            android:id="@+id/button4" />
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:text="Button 3"
            android:id="@+id/button3"/>

    </LinearLayout>

</RelativeLayout>

关于Android 菱形按钮布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35717636/

相关文章:

Java Swing GUI - 问题

android - Image Picker Intent - 在线存储照片的空路径

android - 如何知道android中多选 ListView 中的复选框是否被选中?

java - android获取纵向和横向的可用高度和宽度

android - Row的内容独立可点击区域

java程序卡在while循环中

android - 从 ExpandableListView (Android) 在 ChildView 中添加标题

android - 按钮边距随按钮文本内容而变化

android - 从浏览器打开我的 Android 应用程序的链接

java - 使用按钮将 JTextArea 保存到 .txt 文件