Possible to overlay a Button on top of another?

不羁的心 提交于 2019-12-07 06:13:43

问题


I am trying to overlay a sort of button on top of another button. The reason being I want to explain to the user what certain buttons will do.

For example: There will be a button. In the top right or whatever of that button there will be a question mark. When the user presses the question mark it will explain what that button does.


回答1:


Try using a Relative Layout. Link: http://developer.android.com/reference/android/widget/RelativeLayout.html It'll let you overlay.

Relativelayout will let you align images beside each other easily as well as on top of each other.

Why don't you make the RelativeLayout your button and put your question mark inside it, align it to the right or something.. e.g

<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>

You can attach listeners to both.




回答2:


That's what came to mind, try it:

   <RelativeLayout>
      <Button
        android:id="@+id/btnOne"/>
      <Button
        android:id="@+id/btnTwo"
        android:layout_alignTop="@id/btnOne"
        android:layout_alignLeft="@id/btnOne"/>
    </RelativeLayout>


来源:https://stackoverflow.com/questions/6391402/possible-to-overlay-a-button-on-top-of-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!