可以将Button叠加在另一个上面吗?

IZI*_*IZI 5 android overlay button

我试图在另一个按钮上叠加一种按钮.原因是我想向用户解释某些按钮会做什么.

例如: 将有一个按钮.在右上角或该按钮中的任何一个都会有一个问号.当用户按下问号时,它将解释该按钮的作用.

Igo*_*pov 12

这就是我想到的,尝试一下:

   <RelativeLayout>
      <Button
        android:id="@+id/btnOne"/>
      <Button
        android:id="@+id/btnTwo"
        android:layout_alignTop="@id/btnOne"
        android:layout_alignLeft="@id/btnOne"/>
    </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)


Aid*_*anc 6

尝试使用相对布局.链接:http://developer.android.com/reference/android/widget/RelativeLayout.html它会让你叠加.

Relativelayout可让您轻松地将图像彼此对齐,也可以彼此重叠.

你为什么不把RelativeLayout作为你的按钮,把你的问号放在里面,把它对齐到右边或者什么东西......例如

<RelativeLayout
android:id="@+id/mybutton"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/button_bg"
>
<ImageView
    android:id="@+id/image"
    android:layout_alignParentRight="true"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    style="@style/icon"
    />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

您可以将侦听器附加到两者.