Android 在同一垂直线上对齐复选框

标签 android checkbox vertical-alignment

我想将 Android 中的一组复选框对齐在屏幕中央并位于与单选按钮组类似的同一垂直线上。我在 Internet 上搜索但没有看到任何解决方案。

比如我有一份问卷“你为什么来这家店”,有四个答案1.位置2.服务3.设施4.以上都是。用户可以选择多个答案。

如果我使用单选按钮,我只是将它们分组到一个单选组中。我不知道如何处理复选框。或者我需要使用其他表单小部件。

已编辑

类似于这张图片 https://docs.google.com/file/d/0B9xpIwq2ZRYfQUtYM3RmYVU5VTA/edit

最佳答案

一种方法是将它们全部放在一个LinearLayout中,并给它们每个相同的android:layout_margin Right:

    <LinearLayout
            android:id="@+id/foo"
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginLeft="5dip">
        <CheckBox
                android:id="@+id/bar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="5dip"
                android:text="this is a checkbox"
                android:textColor="@color/Black"
                android:checked="false" />
    </LinearLayout>

关于Android 在同一垂直线上对齐复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25609603/

相关文章:

java - Android程序连接错误

android - loginButton.registerCallback 无法解析方法

python - 有没有办法在 Django 中重新加载后保留 html 复选框状态?

css - 在 IE 怪癖模式下垂直对齐 li 标签内的多行文本

html - 使用 "vertical-align:middle"但我的图像仍未垂直居中

android - Flank Bitrise 步骤失败,因为它找不到结果目录

android - BluetoothGattCallback - onConnectionStateChange 返回 status22

jquery - 如果span包含ID那么

c#-4.0 - 如何在 C# 中动态生成在 DataGridView 内选中的复选框?

css - 如何使用CSS按百分比从顶部推送一个div?