Button and ToggleButton will not align at the same height

I am having problems with the design of the application menu with XML. What I want to do is to have both ToggleButton, and Buttonat the same height, but Buttonnot displayed. It looks like there was something invisible underneath that makes him look a little taller.

I searched for information but didn’t find anything

Here is the code I wrote on main.xml:

(...)    
    <TextView
        android:text="Option1:"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <ToggleButton
        android:id="@+id/toggle_option1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="100sp"
        android:height="50sp" />
    <Button
        android:id="@+id/button_option1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:height="50sp"
        android:text="See" 
    />
    </LinearLayout>

Any idea?

+5
source share
3 answers

Try the following:

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ToggleButton
    android:id="@+id/toggle_option1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:width="100sp"
    android:height="50sp"
    android:layout_marginBottom="5sp" />
<Button
    android:id="@+id/button_option1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:height="50sp"
    android:text="See" 
    android:layout_marginTop="6sp"
/>
</LinearLayout>
+4
source

This is what I did:

<ToggleButton
        android:id="@+id/tbtnAll"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:height="48dp"
         />

<Button
        android:id="@+id/tbtnOther"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:height="50dp"
     />
+2
source
    <ToggleButton 
android:layout_height="wrap_content" 
android:id="@+id/toggle_option1" 
android:layout_width="70dp">
</ToggleButton>
    <Button 
android:id="@+id/button_option1"
 android:text="See" 
android:layout_height="wrap_content"
android:layout_width="70dp">
</Button>
0

All Articles