Android不寻常的图像

m4pnthwp  于 5个月前  发布在  Android
关注(0)|答案(1)|浏览(80)

我正试图在我的android应用程序中创建一个类似的主菜单设计,你可以在我的附件中看到。
问题是,菜单按钮不是水平的,而是倾斜的,部分相互重叠。
我在RelativeLayout中尝试了类似于ImageButton的东西:

<ImageButton
    android:id="@+id/simpleImageButton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/menu1"/>

<ImageButton
    android:id="@+id/simpleImageButton2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/simpleImageButton1"
    android:src="@drawable/menu2"/>

字符串
但由于图像不是水平的,我需要将每个图像存储为具有透明底部和上部的水平图像,然而,这导致这些部分也可以单击,并且由于它们重叠,两个可单击部分将发生碰撞。
有什么好的解决方案可以让它工作吗?
由于这个菜单将被修复,所以没有更多的项目将被添加,我还认为,使它作为一个背景图像,也许以某种方式使无形的按钮只是每个按钮的一部分,或Map以某种方式每个可点击的区域。
但是,我还是更愿意使用ImageData或更简单的方法。


的数据

carvr3hs

carvr3hs1#

您可以尝试使用FrameLayout将多个按钮放置在所需的Angular 并相互重叠。使用属性android:rotationandroid:layout_margin来控制按钮之间的Angular 和重叠。
下面是一个示例:
示例应用程序:https://github.com/bgizdov/android-overlapped-rotated-image-buttons


的数据

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<ImageButton
    android:id="@+id/simpleImageButton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/menu1"
    android:layout_marginTop="50dp"
    android:layout_marginLeft="50dp"
    android:background="@null"
    android:foreground="?android:attr/selectableItemBackground"
    android:rotation="15" />

<ImageButton
    android:id="@+id/simpleImageButton2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/menu2"
    android:layout_marginTop="150dp"
    android:layout_marginLeft="50dp"
    android:background="@null"
    android:foreground="?android:attr/selectableItemBackground"
    android:rotation="-10" />

  <ImageButton
      android:id="@+id/simpleImageButton3"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/menu3"
      android:layout_marginTop="300dp"
      android:layout_marginLeft="50dp"
      android:background="@null"
      android:foreground="?android:attr/selectableItemBackground"
      android:rotation="15" />
</FrameLayout>

字符串

相关问题