gpt4 book ai didi

android - 两部手机上的 CheckBox 间距非常不同

转载 作者:太空宇宙 更新时间:2023-11-03 11:25:28 26 4
gpt4 key购买 nike

我在确定复选框和与之关联的文本之间的间距时遇到了问题。

我的 google galaxy nexus 显示了这个:

screenshot 1

我的 galaxy s2 显示了这个:

screenshot 2

我的布局很简单:

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/transparent_content_box"
android:layout_marginBottom="5dp"
android:orientation="vertical"
>

<CheckBox
android:id="@+id/edit_profile_private_wardrobe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/edit_profile_wardrobe"
style="@style/Theme.CheckBoxHint"
/>

<CheckBox
android:id="@+id/edit_profile_send_me_vouchers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/edit_profile_vouchers"
style="@style/Theme.CheckBoxHint"

/>

<CheckBox
android:id="@+id/edit_profile_third_party_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/edit_profile_email"
style="@style/Theme.CheckBoxHint"
/>

</LinearLayout>

我的风格是:

<style name="Theme.CheckBoxHint">
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/white</item>
</style>

复选框是通过使用可绘制的选择器并使用以下设置来自定义的:

<style name="Theme.CheckBox" parent="android:Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/check_box</item>
</style>

然后在主应用主题中使用:

<item name="android:checkboxStyle">@style/Theme.PMBAppTheme.CheckBox</item>

我曾尝试将复选框的填充设置为 0,但这只会让文本位于复选框本身之上。

如何去除 galaxy s2 上复选框周围的多余间距?

最佳答案

事实证明,设置<item name="android:background">@null</item>在我的 Theme.CheckBoxHint解决了我的问题。必须有一些透明的可绘制对象用作背景。

关于android - 两部手机上的 CheckBox 间距非常不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15274845/

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