开发者

Align checkbox inside a relative layout

I have gridview and I load an image in the grid and a check box to select that image. I use a .9 image as background to show borders for each image. The image and checkbox are inside a relative layout. Now I have tried everything but the checkbox wud not align itself with the border. There is always space b/w the border and the checkbox. This is the view which is loaded in the grid for each image

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageLayout"
android:gravity="top" android:layout_width="fill_parent" android:layout_height="fill_parent">
    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/back"
        android:layout_gravity="center">
    </ImageView>

    <CheckBox
        android:id="@+id/checkbox"
        android:button="@xml/checkbox" 
        android:background="@xml/checkbox_background"
        android:layout_alignRight="@id/ima开发者_开发技巧geLayout"
        android:layout_alignParentRight="true" android:layout_height="wrap_content" android:layout_width="wrap_content" >

    </CheckBox>
</RelativeLayout>

Is there a way I can do it. Attaching screenshot along

Align checkbox inside a relative layout

Edit: the background image I am using is set to the imageview background


Replace

android:layout_alignRight="@id/imageLayout" 

with

android:layout_alignRight="@id/image"

I think you made an error here, because the CheckBox can't be aligned to the right of it's parent relative layout.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜