gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-11-01 08:54:52 25 4
gpt4 key购买 nike

以下 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com