Android Layout: why TextView and ToggleButton don't align

I'm trying to put the TextView and ToggleButton in the table row, however they don't seem to be aligned (the top of the button starts about 10px below the top of the text, even though the height of each item is the same. Can anyone tell me why ?

<TableLayout
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"

        >
    <TableRow>
        <AutoCompleteTextView
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:layout_weight="1"
        />

        <ToggleButton
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        />
        </TableRow>

        </TableLayout>

      

+2


a source to share


1 answer


TableRow behaves like a LinearLayout and tries by default to align widgets with text to their baseline. Set android:layout_gravity="center_vertical"

(or any other gravity setting) to the ToggleButton if you want it to align differently.



+2


a source







All Articles