我在下面给出的个人资料页面中使用了Jake Wharton的
CirclePageIndicator.
图像容器是一个viewpager,圆形指示器显示在它的底部.
我需要将appbar的fitsSystemWindows attr设置为true,以便使bugbars可以运行.但是当使用这个attr circlePagerIndicator消失时.
在此先感谢您的帮助;)
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleEnabled="false"
app:contentScrim="@color/colorPrimary"
app:statusBarScrim="@color/colorPrimaryDark"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
app:layout_collapseMode="none"
android:layout_width="match_parent"
android:layout_height="400dp">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/photo_pager"/>
<com.indate.indicator.CirclePageIndicator
android:id="@+id/indicator"
android:padding="10dip"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignBottom="@+id/photo_pager"
/>
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
android:background="@android:color/transparent"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:elevation="6dp"
app:layout_anchor="@id/app_bar_profile"
app:layout_anchorGravity="bottom|right|end"
app:rippleColor="@color/colorAccentRipple"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_menu_edit"/>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:paddingBottom="8dp"
android:text="John Doe" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:text="1 dk önce" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:textColor="?colorAccent"
android:textSize="12sp"
android:text="ABOUT ME" />
<TextView
android:id="@+id/text_about_me"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:text="Simply me, nothing more..."
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textColor="?colorAccent"
android:textSize="12sp"
android:text="OVERVIEW" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<ImageButton
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@android:color/transparent"
android:src="@drawable/gender"/>
<TextView
android:id="@+id/text_gender_age"
android:padding="8dp"
android:text="M, 28"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<ImageButton
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@android:color/transparent"
android:src="@drawable/pin"/>
<TextView
android:id="@+id/text_place"
android:padding="8dp"
android:text="Ankara, Turkey"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<ImageButton
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@android:color/transparent"
android:src="@drawable/logo"/>
<TextView
android:id="@+id/text_member_since"
android:padding="8dp"
android:text="Member since May 2012"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
最佳答案 AppBarLayout android:fitsSystemWindows =“true”让它在某种程度上与CollapsingToolbarLayout中的RelativeLayout混淆.似乎有一个bug.所以我删除它,它就像一个魅力.
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleEnabled="false"
app:contentScrim="@color/colorPrimary"
app:statusBarScrim="@color/colorPrimaryDark"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="400dp"
android:id="@+id/photo_pager"/>
<com.indate.indicator.CirclePageIndicator
android:id="@+id/indicator"
android:padding="10dip"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="bottom"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
android:background="@android:color/transparent"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:elevation="6dp"
app:layout_anchor="@id/app_bar_profile"
app:layout_anchorGravity="bottom|right|end"
app:rippleColor="@color/colorAccentRipple"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_menu_edit"/>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:paddingBottom="8dp"
android:text="John Doe" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:text="1 dk önce" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:textColor="?colorAccent"
android:textSize="12sp"
android:text="ABOUT ME" />
<TextView
android:id="@+id/text_about_me"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:text="Simply me, nothing more..."
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textColor="?colorAccent"
android:textSize="12sp"
android:text="OVERVIEW" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<ImageButton
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@android:color/transparent"
android:src="@drawable/gender"/>
<TextView
android:id="@+id/text_gender_age"
android:padding="8dp"
android:text="M, 28"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<ImageButton
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@android:color/transparent"
android:src="@drawable/pin"/>
<TextView
android:id="@+id/text_place"
android:padding="8dp"
android:text="Ankara, Turkey"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<ImageButton
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@android:color/transparent"
android:src="@drawable/logo"/>
<TextView
android:id="@+id/text_member_since"
android:padding="8dp"
android:text="Member since May 2012"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>