我尝试将两个按钮(带有可正常工作的图像)并排放置并水平对中。这是我迄今为止:水平居中两个按钮
<LinearLayout android:orientation="horizontal" android:layout_below="@id/radioGroup"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center">
<Button
android:id="@+id/allow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/radioGroup"
android:layout_gravity="center_horizontal"
android:drawableLeft="@drawable/accept_btn"
android:text="Allow"/>
<Button
android:id="@+id/deny"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/allow"
android:layout_below="@id/radioGroup"
android:layout_gravity="center_horizontal"
android:drawableLeft="@drawable/block_btn"
android:text="Deny"/>
</LinearLayout>
不幸的是,他们仍然对齐左侧。任何帮助表示赞赏!伊夫
编辑:
遗憾的是没有任何意见或建议的工作至今。这就是为什么我现在尝试提供一种简化的,完整的布局与RelativeLayout的:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<TextView android:text="@+id/TextView01" android:id="@+id/TextView01"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<Button
android:id="@+id/allow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/TextView01"
android:text="Allow"/>
<Button
android:id="@+id/deny"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/allow"
android:layout_alignTop="@id/allow"
android:text="Deny"/>
</RelativeLayout>
我已经试过在的LinearLayout和没有运气的按钮元素属性的所有组合。任何其他想法?
有多大的按钮?他们会像你想要他们一样肩并肩吗? – prolink007 2010-11-15 23:32:46
是的,这完全没有问题。目前他们并排出现,但他们坚持左侧。 – Yves 2010-11-15 23:36:29
哦,我明白你的问题是什么,我错过了这个问题。我以为你说你不能让他们水平排队。 – prolink007 2010-11-15 23:38:24