Android 复选框文本显示在框的顶部

Android 复选框文本显示在框的顶部,android,layout,checkbox,android-4.2-jelly-bean,overlapping,Android,Layout,Checkbox,Android 4.2 Jelly Bean,Overlapping,下面的XML显示了一系列用于选择语言的复选框。它在JB 4.2中看起来不错,但是JB 4.1中的相同布局在复选框顶部有文本。像这样: 有什么我没有按照标准做的吗 代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical

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

有什么我没有按照标准做的吗

代码:

<?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>

增加复选框中的空白

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

引用,问题似乎是Android的复选框控件已经使用了
Android:paddingLeft
属性来获取文本。如果覆盖它,可能会使布局混乱。因此,如果您删除了
android:paddingLeft=“10dp”
android:layout\u marginLeft=“10dp”
,它应该可以做到这一点

在复选框中添加以下值解决了我的问题

android:gravity="center"

你能发布外部布局规范吗?很抱歉,我这么做了,所以出于某种原因没有选择它,现在你可以看到它了。当你从修复它的
@ShobhitPuri中删除
android:paddingLeft=“10dp”和
android:layout\u marginLeft=“10dp”
时会发生什么!但我不知道为什么…主要是因为您覆盖了padding属性。请阅读以下内容:。这将有助于你理解原因:)是的,我可以添加填充,但这似乎有点麻烦,它会影响我在手机上的布局吗?如果没有这个,它会看起来很好吗?如果你担心多分辨率屏幕,没有问题,因为40 dp不会影响布局的主要组织