android - 复选框文本显示在框顶部

标签 android layout checkbox android-4.2-jelly-bean overlapping

以下 XML 显示了一系列用于选择语言的复选框。它在 JB 4.2 中看起来不错,但 JB 4.1 上的相同布局将文本放在复选框顶部。就像这样:

enter image description here

我有什么不符合标准的事情吗?

代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">


    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Language Setup"
            android:id="@+id/textView1"
            android:layout_gravity="center"
            android:textSize="30dp"
            android:paddingBottom="10dp"/>
    <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Please select the languages you would like :"
            android:id="@+id/textView"
            android:layout_marginLeft="10dp"/>

    <CheckBox android:id="@+id/chkInstallArabic"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Arabic"
              android:checked="true"
              android:enabled="false"
              android:paddingLeft="10dp"
              android:layout_marginLeft="10dp"/>

    <CheckBox android:id="@+id/chkInstallEnglish"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="English"
              android:checked="false"
              android:paddingLeft="10dp"
              android:layout_marginLeft="10dp"/>

    <CheckBox android:id="@+id/chkInstallUrdu"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Urdu"
              android:checked="false"
              android:paddingLeft="10dp"
              android:layout_marginLeft="10dp"/>

    <CheckBox android:id="@+id/chkInstallIndonesian"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Indonesian"
              android:checked="false"
              android:paddingLeft="10dp"
              android:layout_marginLeft="10dp"/>

    <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="I am happy!"
            android:id="@+id/btnInstall"
            android:onClick="onRunButtonClicked"
            />
</LinearLayout>

最佳答案

引用Android - Spacing between CheckBox and text ,问题似乎是 Android 的 CheckBox 控件已经使用 android:paddingLeft 属性来获取文本所在的位置。如果您覆盖它,可能会弄乱布局。因此,如果您删除 android:paddingLeft="10dp"android:layout_marginLeft="10dp",它应该可以解决问题。

关于android - 复选框文本显示在框顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19941705/

相关文章:

将 EAP 与 PEAP 结合使用时,Android 身份验证会陷入僵局

Android 用例单元测试

jquery - 拆分将显示在多个列上的内容

css - 边界半径随着溢出规则消失

javascript - 如何在未选中复选框时禁用 PHP 禁用和清除文本框。根据数据库选中/取消选中复选框

javascript - 使用 .prop() 进行检查和禁用的 jquery 1.6.2 问题

java - 我如何监控另一个应用程序的数据库变化?

android - MPAndroidChart - X 轴仅在顶部绘制标签

android - 获取应用页面中的所有按钮

javascript - 复选框值的总和