Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button and ToggleButton won't align at same height

I'm having troubles designing the menu of an application with XML. What I want to do is to have both ToggleButton and Button at same height, but the Button doesn't appear aligned. It's like if it had something invisible below it that makes it appear a little higher.

I've been looking for info, but I found nothing

Here's the code I wrote on the 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?

like image 822
ArcDare Avatar asked Oct 21 '11 10:10

ArcDare


1 Answers

Try this:

<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>
like image 84
Carnal Avatar answered Sep 29 '22 23:09

Carnal