【问题标题】:Android CoordinatorLayout hides/overlays main viewAndroid CoordinatorLayout 隐藏/覆盖主视图
【发布时间】:2015-07-10 07:24:56
【问题描述】:

我在里面使用 CoordinatorLayout 和 ViewPager。问题是,列表的第一个条目(在 ViewPager 的第一页中)被选项卡隐藏了。当我使用 LinearLayout 而不是 CoordinatorLayout 时,一切正常。

  1. 如何修复这种重叠?
  2. 应该在此处添加 FloatingButton 还是在 ListView XML 中添加?

这是 XML:

<?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"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.TabLayout
            android:id="@+id/sliding_tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
            android:id="@+id/pager_list_views"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    </android.support.v4.view.ViewPager>

    <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:layout_margin="16dp"
            android:src="@android:drawable/ic_menu_add"
            app:layout_anchor="@id/pager_list_views"
            app:layout_anchorGravity="bottom|right|end" />

</android.support.design.widget.CoordinatorLayout>

【问题讨论】:

    标签: android android-xml android-coordinatorlayout floating-action-button


    【解决方案1】:

    将此添加到 ViewPager

      app:layout_behavior="@string/appbar_scrolling_view_behavior"
    

    如果您使用CoordinatorLayout,则必须指定一种行为,如果您控制设计的这些方面会更安全。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-28
      • 1970-01-01
      相关资源
      最近更新 更多