1

内部で CoordinatorLayout と ViewPager を使用しています。問題は、リストの最初のエントリ (ViewPager の最初のページ) がタブによって隠されていることです。CoordinatorLayout の代わりに LinearLayout を使用すると、すべて正常に動作します。

  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>
4

1 に答える 1

2

これを ViewPager に追加します

  app:layout_behavior="@string/appbar_scrolling_view_behavior"

使用するCoordinatorLayout場合は、動作を指定する必要があります。設計のこれらの側面を制御すると安全です。

于 2015-07-10T07:27:54.857 に答える