uguboz uguboz - 1 month ago 10
Android Question

AppBarLayout fitsSystemWindows true attr makes CircularIndicator invisible

I am using Jake Wharton's CirclePageIndicator in my profile page given below.

Image container is a viewpager and circlepage indicator shows at the bottom of it.

And i needed to set appbar's fitsSystemWindows attr as true for a bug afaik to make statusbarscrim work. But when use this attr circlePagerIndicator disappears.

Thanks for ur help in advance ;)




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



Answer

AppBarLayout android:fitsSystemWindows="true" makes it confused with RelativeLayout inside CollapsingToolbarLayout somehow. it seems there is a bug. So i removed it and it worked like a charm.

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