Search code examples
androidandroid-relativelayout

Android - RelativeLayout - position a checkbox on the center of an image


I would like to know how can I center a checkbox to an image on my RelativeLayout view - there is no property like this..

Here's my code:

http://pastebin.com/tGAxju3Z

Please notice: the image is bigger then the checkbox.


Solution

  • Use FrameLayout for the following

    <FrameLayout 
    android:id="@+id/button1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/image1"
    >
    
    <Button
    android:id="@+id/button2"
    android:layout_gravity="center"
    android:src="@drawable/image2" />
    
    </FrameLayout>