我想製作一個基本的計算器應用程序,所以我開始爲每個數字和操作製作按鈕。爲了讓它們對齊,我使用了一個RelativeLayout,但在它下面我有五個LinearLayout,每個LinerarLayout代表一排按鈕。如何對齊兩個LinearLayouts?
我的問題是以下,我使用layout_alignBottom
第一行爲了保持它在屏幕的底部,我試圖用layout_above
對齊第一行上面的第二行,但似乎我可以'噸做到這一點,因爲我得到一個No resource found that matches the given name (at 'layout_above' with value '@id/firstRow').
錯誤,實際上我得到這個錯誤的所有對齊屬性。
這裏是我的xml的一部分
<LinearLayout
android:id="@+id/secondRow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="@id/firstRow">
<Button
android:id="@+id/b1"
android:layout_width="85dp"
android:layout_height="85dp"
android:text="1" />
<!-- more buttons -->
</LinearLayout>
<LinearLayout
android:id="@+id/firstRow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
<Button
android:id="@+id/bP"
android:layout_width="85dp"
android:layout_height="85dp"
android:layout_marginLeft="0dp"
android:text="." />
<!-- more buttons -->
</LinearLayout>
我該如何調整的LinearLayouts在方式,第一行是在屏幕的底部,其它的是一個每個人的上面?