Android CheckBox额外填充TouchWiz [英] Android CheckBox extra padding on TouchWiz

查看:248
本文介绍了Android CheckBox额外填充TouchWiz的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个布局包含一个TextView和一个复选框,这看起来像我预期在Galaxy Nexus(4.2.2):

I have a layout which contains a TextView and a CheckBox, and this looks as expected on my Galaxy Nexus (4.2.2):

但是当在Galaxy S3上查看时, S2,我得到一些奇怪的填充到顶部,右侧和底部的复选框,这是搞乱了整个子视图的水平对齐:

However when viewing on a Galaxy S3 and S2, I get some odd padding to the top, right and bottom of the CheckBox which is messing up the horizontal alignment of the whole subview:

XML布局:

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ll_vert"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center_horizontal" >

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <LinearLayout
        android:id="@+id/ll_horz"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="5dp" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="5dp"
            android:text="Some Text"
            android:textSize="14sp" />

        <CheckBox
            android:id="@+id/cb"
            android:gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>

</LinearLayout>

更明显的是,如果我使用一个自定义复选框资源的选择器做):

It's even more obvious if I used a selector for a custom checkbox resource (which I'm ultimately trying to do):

    <CheckBox
        android:id="@+id/cb"
        android:gravity="center"
        android:button="@drawable/selector_checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

Galaxy S3:

Galaxy Nexus:

有人遇到过这个吗?显然,gravity =center似乎对TouchWiz没有效果...

Anyone else experienced this? Obviously the gravity="center" appears to have no effect on TouchWiz...

EDIT 10-SEP -2013 -

我在修复中被入侵了

if (android.os.Build.MANUFACTURER.equals("samsung") && android.os.Build.MODEL.startsWith("GT-")) {

    LinearLayout llHorz = (LinearLayout)view.findViewById(R.id.ll_horz);            
    llHorz.setPadding(Math.round(getResources().getDisplayMetrics().density * 20f), llHorz.getPaddingTop(), llHorz.getPaddingRight(), llHorz.getPaddingBottom());   
}

这不太理想,但现在可以达到目的。

This is less than ideal but it serves its purpose for now.

推荐答案

与galaxy s2有相同的问题。在三星遥控测试实验室测试结果,也是Android版本是相关的。似乎三星已经固定在较新的版本。

had the same issue with an galaxy s2. Tested at the Samsung Remote Test Lab with the Result, that also the Android version is relevant. Seems that Samsung has fixed it on newer Versions.

    if (Build.MANUFACTURER.equals("samsung") && Build.MODEL.startsWith("GT-") && Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)

这篇关于Android CheckBox额外填充TouchWiz的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆