【发布时间】:2013-11-25 08:11:43
【问题描述】:
以下 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:paddingLeft="10dp"和android:layout_marginLeft="10dp"会发生什么? -
@ShobhitPuri 已修复!但我不知道为什么......
-
主要是因为你覆盖了 padding 属性。阅读:stackoverflow.com/questions/4037795/…。它将帮助您了解原因:)
标签: android layout checkbox android-4.2-jelly-bean overlapping