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