Cal*_*alc 9 android android-fragments android-design-library android-coordinatorlayout android-appbarlayout
我正在使用下面的布局,其中的CoordinatorLayout内部AppBarLayout(包含Toolbar和TabLayout内部)和占位符RelativeLayout,所以我可以在其上添加和替换片段.
我遇到了边距错误,我在RelativeLayout上添加的碎片将总是超出屏幕底部(与AppBarLayout高度大小相似的数量),我尝试将它的高度设置为wrap_content和match_parent,在这两种情况下它太过分了.
如果我app:layout_behavior="@string/appbar_scrolling_view_behavior"从RelativeLayout顶部移除它将在其下AppBarLayout也不是所希望的结果.
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
app:tabIndicatorHeight="4dp"
app:tabIndicatorColor="#ffffff"
app:tabMode="scrollable"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/main_fragment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="20dp"
android:src="@drawable/ic_done" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header"
app:menu="@menu/drawer_view"/>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
通过更新 recyclerview 库(更新为 com.android.support:recyclerview-v7:22.2.0)解决了该问题
我正在加载的片段中有一个回收视图。
| 归档时间: |
|
| 查看次数: |
7979 次 |
| 最近记录: |