我是Android開發的小菜鳥,我在構建佈局時遇到問題。我有一個包含textview和包含兩個複選框的線性佈局的相對佈局。我希望textView顯示在左側,線性佈局顯示在線性佈局的右側與邊緣齊平。目前,textview和linearlayout顯示在彼此之上。任何幫助是極大的讚賞。爲什麼alignParentRight不能正常工作?
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="Rotated Shelf: "
android:layout_gravity="center_vertical"/>
<LinearLayout
android:id="@+id/rotated"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_alignParentRight="true">
<CheckBox
android:id="@+id/rotatedshelfYES"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yes"
android:layout_toLeftOf="@+id/rotatedshelfNO"
/>
<CheckBox
android:id="@+id/rotatedshelfNO"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="75dp"
android:text="No"
android:layout_alignParentRight="true" />
</LinearLayout>
</RelativeLayout>
部分是你的LinearLayout設置爲'寬:「match_parent」'這意味着它將會是屏幕的全尺寸。嘗試將其更改爲「wrap_content」,該值應該足夠大以適應複選框,該複選框應該有足夠空間向右邊移動。 – FoamyGuy 2013-04-09 13:57:13