vendredi 27 février 2015

Removing annoying checkbox padding at android 4.1.2+

I got a problem with padding of checkbox to the next element (editview) within a gridlayout - how can i get rid of the extra space in here (see green marker in my picture)?


I tried to create a custom checkbox class and overwrite getCompoundPadingLeft, tried layout_marginRight="0", paddingRight="0", paddingLeft="0", ... nothing worked.


The only thing which worked, was negative margin layout_marginRight="-10dp". But this is getting a problem on two different devices. Where the editview is close to the checkbox on device 1 (Samsung Galaxy S2), it is inside the checkbox on device 2 (LG G2).


Any ideas?


Screenshot: enter image description here


Code:



<GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">

<!-- ... -->

<TextView
android:id="@+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="1"
android:text="Zone1" />

<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_row="1"
android:checked="true"
android:tag="110"/>

<EditText
android:id="@+id/edit1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_row="1"
android:width="50dp"
android:ems="10"
android:inputType="number"
android:numeric="integer"
android:selectAllOnFocus="true"
android:text="20" />

<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:layout_row="1"
android:checked="true" />

<EditText
android:id="@+id/edit2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="4"
android:layout_row="1"
android:width="50dp"
android:ems="10"
android:inputType="number"
android:numeric="integer"
android:selectAllOnFocus="true"
android:text="14" />

<CheckBox
android:id="@+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="5"
android:layout_row="1"
android:checked="true" />

<EditText
android:id="@+id/edit3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="6"
android:layout_row="1"
android:width="50dp"
android:ems="10"
android:inputType="number"
android:numeric="integer"
android:selectAllOnFocus="true"
android:text="8" />




Aucun commentaire:

Enregistrer un commentaire