【问题标题】:Align checkbox inside a relative layout在相对布局内对齐复选框
【发布时间】:2011-09-24 04:28:00
【问题描述】:

我有 gridview,我在网格中加载了一个图像,并使用一个复选框来选择该图像。我使用 .9 图像作为背景来显示每个图像的边框。图像和复选框位于相对布局内。现在我已经尝试了所有方法,但复选框 wud 没有与边框对齐。边框和复选框总是有空格。这是为每个图像加载到网格中的视图

<?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/imageLayout"
        android:layout_alignParentRight="true" android:layout_height="wrap_content" android:layout_width="wrap_content" >

    </CheckBox>
</RelativeLayout>

有什么办法可以做到。附上截图

编辑:我使用的背景图片设置为 imageview 背景

【问题讨论】:

    标签: android gridview checkbox android-relativelayout


    【解决方案1】:

    替换

    android:layout_alignRight="@id/imageLayout" 
    

    android:layout_alignRight="@id/image"
    

    我认为您在这里犯了一个错误,因为 CheckBox 无法与其父相对布局的右侧对齐。

    【讨论】:

    • 我已经试过了,现在我又试了一次,还是一样。你说的错是什么意思,你的意思是不能做??
    猜你喜欢
    • 1970-01-01
    • 2012-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多