我在Android(Studio 3.0)的第一次尝试中设法实现了底部导航和片段.
现在,当在第一个Fragment上实现Widgets时,我意识到底部导航正在覆盖/隐藏片段的最低部分.
Fragment包含两个布局,一个listview和两个按钮:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.xyz.ticketvendor.QuickRideFragment">
<!-- TODO: Update blank fragment layout -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ListView
android:id="@+id/lvTransportLines"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<LinearLayout
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignBottom="@id/lvTransportLines">
<Button
android:id="@+id/getTicket"
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_weight=".75"
android:text="Get Ticket" >
</Button>
<Button
android:id="@+id/setDefaultSMSApp"
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_weight=".25"
android:text="Reset" >
</Button>
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我正在使用android:layout_alignBottom="@id/lvTransportLines"LinearLayout(它保留2个按钮)位于Listview下方.我只能看到按钮,因为我将测试目的的高度设置为巨大的.
但是 - 我可以使用哪个布局属性将LinearLayout定位到足够高,以免被底部导航隐藏?谢谢!
实施@Nero解决方案后更新我想出了这个:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.antibala.ticketvendor.QuickRideFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ListView
android:id="@+id/lvTransportLines"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:id="@+id/buttons" …Run Code Online (Sandbox Code Playgroud) java android android-layout android-fragments android-studio-3.0