Кнопка и ToggleButton не будут выравниваться на одной высоте - PullRequest
5 голосов
/ 21 октября 2011

У меня проблемы с проектированием меню приложения с XML. Я хочу, чтобы и ToggleButton, и Button были на одной высоте, но Button не выровнено. Это как если бы под ним было что-то невидимое, что заставляло бы его казаться немного выше.

Я искал информацию, но ничего не нашел

Вот код, который я написал на 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>

Есть идеи?

Ответы [ 3 ]

4 голосов
/ 21 октября 2011

Попробуйте это:

<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>
2 голосов
/ 14 июня 2012

Вот что я сделал:

<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"
     />
0 голосов
/ 21 октября 2011
    <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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...