我對Android非常陌生。我有一個非常簡單的佈局尚不工作:在活動中顯示片段下方的按鈕
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout">
<fragment android:layout_width="fill_parent"
android:layout_height="match_parent"
android:name="pl.nscr.playwatch.MainActivity$WatchListFragment"
android:id="@+id/watchlist"/>
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Start service"/>
</LinearLayout>
現在我的問題是,該片段跨越一個活動的整體可用高度。我希望能夠看到它下面的那個按鈕,但我實際上不知道如何佈置這個東西。
我嘗試過使用RelativeLayout,但我最終顯示了醜陋的片段上方的按鈕。我究竟做錯了什麼?
更新
顯然,這是一個愚蠢的錯誤。我再次改回RelativeLayout,但佈局現在將寬度和高度設置爲「fill_parent」,並且所有內容都按預期工作。
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout">
<fragment android:layout_width="fill_parent"
android:layout_height="match_parent"
android:name="pl.nscr.playwatch.MainActivity$WatchListFragment"
android:id="@+id/watchlist"
android:layout_above="@+id/btnStartService"/>
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="@id/btnStartService"
android:text="Start service"/>
</RelativeLayout>