【发布时间】:2017-04-15 03:31:17
【问题描述】:
我有这个布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="ca.usherbrooke.whapl.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:elevation="4dp"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:background="@color/colorPrimary"
>
<ImageView
android:id="@+id/previous"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_action_previous"/>
<ImageView
android:id="@+id/play_pause"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_action_play"/>
<ImageView
android:id="@+id/next"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_action_next"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:background="@color/colorPrimary"
>
<TextView
android:layout_marginLeft="10dp"
android:id="@+id/songname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
/>
</LinearLayout>
</LinearLayout>
当我的fragment_container 中有一个 ListView 时,带有播放/暂停/下一个/倒带按钮的播放器总是在容器上方,所以我无法访问列表视图中的最后一个元素,因为它在我的播放器后面( fragment_container 之后的线性布局)。
我应该为容器更改哪些内容,只占用他拥有的位置,而不是放在我的播放器下方?
顺便说一下,这个布局包含在我的主要活动的布局中,这是一个包含我的容器 + NavigationView 的 DrawerLayout。
【问题讨论】:
-
考虑使用 LinearLayout 或 RelativeLayout 对其进行变形以使其正常工作。创建 Linearlayout 并将您的 appbarlayout 和 framelayout 放入其中。
标签: android layout fragment android-linearlayout android-coordinatorlayout