android - 如何在线性布局中将元素放置得更近?

标签 android android-linearlayout

我有这样的 Activity :

enter image description here

如您所见,复选框下方的底部不适合屏幕。如何使复选框在线性布局中靠得更近?

这是 XML(只有复选框 + 按钮):

    <LinearLayout
    android:layout_width="591dp"
    android:layout_height="match_parent"
    android:layout_weight="0.20" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="left|center_vertical|center_horizontal"
        android:orientation="vertical" >

        <CheckBox
            android:id="@+id/checkBox8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="100dp"
            android:text="@string/madurez_2" />

        <CheckBox
            android:id="@+id/checkBox1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="130dp"
            android:text="@string/gestion_configuracion"
            android:textSize="12sp" />

        <CheckBox
            android:id="@+id/checkBox2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="130dp"
            android:text="@string/medicion_analisis"
            android:textSize="12sp" />

        <CheckBox
            android:id="@+id/checkBox3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="130dp"
            android:text="@string/monitorizacion_control"
            android:textSize="12sp" />

        <CheckBox
            android:id="@+id/checkBox4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="130dp"
            android:text="@string/planificacion_proyecto"
            android:textSize="12sp" />

        <CheckBox
            android:id="@+id/checkBox5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="130dp"
            android:text="@string/aseguramiento_calidad"
            android:textSize="12sp" />

        <CheckBox
            android:id="@+id/checkBox6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="130dp"
            android:text="@string/gestion_requisitos"
            android:textSize="12sp" />

        <CheckBox
            android:id="@+id/checkBox7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="130dp"
            android:text="@string/gestion_acuerdos"
            android:textSize="12sp" />

        <Button
            android:id="@+id/button2"
            android:layout_width="142dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="170dp"
            android:layout_marginTop="20dp"
            android:text="@string/comenzar" />
    </LinearLayout>

</LinearLayout>

最佳答案

 android:layout_marginTop="-10dp"

您可以在所有复选框上添加带有减号 (-) 的顶部填充,顶部的第一个除外,在这种情况下为 -10,但您可以选择适合您的任何东西......那应该把它们放近一点

关于android - 如何在线性布局中将元素放置得更近?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17095517/

相关文章:

android - android项目最好的静态代码分析工具是什么?

android - 如何订购这样的元素?

xml - android View 中经常出现的问题,解析XML时出错: unbound prefix

android - 如何在 android 中使用拖放框架从一个 LinearLayout 交换到另一个 LinearLayout

java - 如何处理写入 CSV 文件的字段中的输入键?

Android - 如何在长生命周期后台线程中运行套接字

android - 有什么方法可以查看我们自己的 android 应用程序的日志消息吗?

android - scrollview 在 android 中太慢

android - 自定义按钮填充和文本大小问题

android - 如何创建一个创建不连续边框的 xml 可绘制对象?