我試圖讓我的TextView擁抱屏幕的左側,而按鈕的擁抱右側(如果可能的話只是爲了強迫症有文本視圖垂直居中以符合按鈕),但不能使用絕對值。這裏是我的編碼:的TextView在左側與右側非絕對值按鈕
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="100px"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="Change City:"
/>
<Button
android:layout_width="100px"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="Click"
android:id="@+id/citychoicebutton"
/>
</LinearLayout>
我以爲layout_gravity照顧了我想要做的,但顯然不是。
香港專業教育學院發現,如果我使用tablelayout而非LinearLayout中我可以得到TextView的垂直使用的android上的按鈕中心:layout_alignLeft /右,但我仍然無法得到按鈕擁抱屏幕的右側 – dootcher 2010-08-10 05:57:16