开发者

android: align Button and ToggleButton horizontally in LinearLayout or RelativeLayout

if I try to align the toggle inbetween two buttons within a LinearLayo开发者_开发技巧ut, I always come up with something where the toggle is slightly misaligned by about 2px to the bottom. I tried a RelativeLayout and also android:layout_gravity=""center_vertical".

Thanx, Huck


I just added android:layout_gravity=""center_vertical" to both controls and the desaligment dissapears. although I am using SDK 2.3.3


Like the guy above said : This works perfectly..

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<Button  android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_gravity="center_vertical" />   

<ToggleButton
android:id="@+id/toggleButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ToggleButton"
android:layout_gravity="center_vertical" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" 
android:layout_gravity="center_vertical"/>

</LinearLayout>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜