Android 在活动中的片段下方显示按钮
我对安卓系统还很陌生。我有一个非常简单的布局,但还不起作用:Android 在活动中的片段下方显示按钮,android,layout,Android,Layout,我对安卓系统还很陌生。我有一个非常简单的布局,但还不起作用: <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relativeLayout">
<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>
将android:orientation=“vertical”添加到线性布局。执行以下操作