How do I correctly implement toolbars inside fragments in viewpager?
I have a collapsing toolbar in my TimelineFragment
which I recently added. And there is an already existing collapsing toolbar which previously worked fine in my ProfileFragment
until when I added the similar toolbar to the TimelineFragment
. Both of these fragments are contained in a view pager.
I have the ff layout for the ProfileFragment
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/ivProfileAvatar"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/divider_small"
android:src="@drawable/profile_image" />
<Space
android:layout_width="match_parent"
android:layout_height="@dimen/divider_small" />
<TextView
android:id="@+id/tvUserUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="JuanOne"
android:textColor="@android:color/white"
android:textSize="@dimen/text_header"
android:textStyle="bold" />
<TextView
android:id="@+id/tvUserCommunity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="University Name"
android:textColor="@android:color/white"
android:textSize="@dimen/text_content" />
<TextView
android:id="@+id/tvUserBio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Still learning to face difficulty"
android:textColor="@android:color/white"
android:textSize="@dimen/text_content" />
<Space
android:layout_width="match_parent"
android:layout_height="@dimen/divider_normal" />
<Button
android:id="@+id/btnEditProfile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/btn_gradient_blue"
android:paddingStart="48dp"
android:paddingEnd="48dp"
android:text="Edit Profile"
android:textAllCaps="false"
android:textColor="@android:color/white" />
<!--
DO NOT CHANGE,
CHANGE ONLY IF TOOLBAR SIZE (FOR TAB_LAYOUT) IS ALSO CHANGED
-->
<Space
android:layout_width="match_parent"
android:layout_height="56dp" />
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
app:layout_collapseMode="pin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.design.widget.TabLayout
android:id="@+id/tabsProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
app:tabBackground="@null"
app:tabGravity="center"
app:tabIndicatorColor="@android:color/white"
app:tabIndicatorHeight="2dp">
<android.support.design.widget.TabItem
android:id="@+id/tabProfileMySSSS"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<android.support.design.widget.TabItem
android:id="@+id/tabProfileMySSSSS"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.design.widget.TabLayout>
<ImageButton
android:id="@+id/ibtnProfileTimelineRefresh"
android:layout_width="128dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_marginRight="@dimen/divider_normal"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_autorenew_white_24dp" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
which is inside a CoordinatorLayout
and the ff layout for the TimelineFragment
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="92dp">
<android.support.design.widget.AppBarLayout
android:fitsSystemWindows="true"
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/cvCreateSSSSS"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/divider_small"
android:layout_marginRight="@dimen/divider_small"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="8dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="@dimen/divider_normal">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/svg_nav_create_SSSSSS" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="@dimen/divider_normal"
android:text="What's on your mind?"
android:textColor="@android:color/black"
android:textSize="@dimen/text_content" />
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="@dimen/divider_xsmall"
android:src="@drawable/svg_insert_image" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:visibility="gone">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<...some other layouts />
</android.support.design.widget.CoordinatorLayout>
For visuals on what my issue is
** This image is from the ProfileFragment
The extra space which I marked red has not existed before, when I still haven't added the AppBarLayout
(containing the toolbar) on the TimelineFragment
.
I have tried removing the whole AppBarLayout
on the TimelineFragment
, and it does fix the weird extra space on the ProfileFragment
. Why is it that there is a relation between these fragments when they do not share anything besides being in the same ViewPager
?
How do I remove the space that I marked red on the image? It might be related to the toolbar since it is same in color. The AppBarLayout
uses a lighter color than the toolbar.
android android-layout android-viewpager android-toolbar android-collapsingtoolbarlayout
add a comment |
I have a collapsing toolbar in my TimelineFragment
which I recently added. And there is an already existing collapsing toolbar which previously worked fine in my ProfileFragment
until when I added the similar toolbar to the TimelineFragment
. Both of these fragments are contained in a view pager.
I have the ff layout for the ProfileFragment
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/ivProfileAvatar"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/divider_small"
android:src="@drawable/profile_image" />
<Space
android:layout_width="match_parent"
android:layout_height="@dimen/divider_small" />
<TextView
android:id="@+id/tvUserUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="JuanOne"
android:textColor="@android:color/white"
android:textSize="@dimen/text_header"
android:textStyle="bold" />
<TextView
android:id="@+id/tvUserCommunity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="University Name"
android:textColor="@android:color/white"
android:textSize="@dimen/text_content" />
<TextView
android:id="@+id/tvUserBio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Still learning to face difficulty"
android:textColor="@android:color/white"
android:textSize="@dimen/text_content" />
<Space
android:layout_width="match_parent"
android:layout_height="@dimen/divider_normal" />
<Button
android:id="@+id/btnEditProfile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/btn_gradient_blue"
android:paddingStart="48dp"
android:paddingEnd="48dp"
android:text="Edit Profile"
android:textAllCaps="false"
android:textColor="@android:color/white" />
<!--
DO NOT CHANGE,
CHANGE ONLY IF TOOLBAR SIZE (FOR TAB_LAYOUT) IS ALSO CHANGED
-->
<Space
android:layout_width="match_parent"
android:layout_height="56dp" />
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
app:layout_collapseMode="pin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.design.widget.TabLayout
android:id="@+id/tabsProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
app:tabBackground="@null"
app:tabGravity="center"
app:tabIndicatorColor="@android:color/white"
app:tabIndicatorHeight="2dp">
<android.support.design.widget.TabItem
android:id="@+id/tabProfileMySSSS"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<android.support.design.widget.TabItem
android:id="@+id/tabProfileMySSSSS"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.design.widget.TabLayout>
<ImageButton
android:id="@+id/ibtnProfileTimelineRefresh"
android:layout_width="128dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_marginRight="@dimen/divider_normal"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_autorenew_white_24dp" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
which is inside a CoordinatorLayout
and the ff layout for the TimelineFragment
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="92dp">
<android.support.design.widget.AppBarLayout
android:fitsSystemWindows="true"
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/cvCreateSSSSS"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/divider_small"
android:layout_marginRight="@dimen/divider_small"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="8dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="@dimen/divider_normal">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/svg_nav_create_SSSSSS" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="@dimen/divider_normal"
android:text="What's on your mind?"
android:textColor="@android:color/black"
android:textSize="@dimen/text_content" />
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="@dimen/divider_xsmall"
android:src="@drawable/svg_insert_image" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:visibility="gone">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<...some other layouts />
</android.support.design.widget.CoordinatorLayout>
For visuals on what my issue is
** This image is from the ProfileFragment
The extra space which I marked red has not existed before, when I still haven't added the AppBarLayout
(containing the toolbar) on the TimelineFragment
.
I have tried removing the whole AppBarLayout
on the TimelineFragment
, and it does fix the weird extra space on the ProfileFragment
. Why is it that there is a relation between these fragments when they do not share anything besides being in the same ViewPager
?
How do I remove the space that I marked red on the image? It might be related to the toolbar since it is same in color. The AppBarLayout
uses a lighter color than the toolbar.
android android-layout android-viewpager android-toolbar android-collapsingtoolbarlayout
you are using android:layout_marginTop="92dp" in your CoordinatorLayout tag remove this and check
– Imtiaz Abir
Jan 4 at 5:26
and also you can use these propertiees in Coordinator layout: android:layout_height="0dp" android:layout_weight="1" android:fitsSystemWindows="true"
– Imtiaz Abir
Jan 4 at 5:31
add a comment |
I have a collapsing toolbar in my TimelineFragment
which I recently added. And there is an already existing collapsing toolbar which previously worked fine in my ProfileFragment
until when I added the similar toolbar to the TimelineFragment
. Both of these fragments are contained in a view pager.
I have the ff layout for the ProfileFragment
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/ivProfileAvatar"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/divider_small"
android:src="@drawable/profile_image" />
<Space
android:layout_width="match_parent"
android:layout_height="@dimen/divider_small" />
<TextView
android:id="@+id/tvUserUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="JuanOne"
android:textColor="@android:color/white"
android:textSize="@dimen/text_header"
android:textStyle="bold" />
<TextView
android:id="@+id/tvUserCommunity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="University Name"
android:textColor="@android:color/white"
android:textSize="@dimen/text_content" />
<TextView
android:id="@+id/tvUserBio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Still learning to face difficulty"
android:textColor="@android:color/white"
android:textSize="@dimen/text_content" />
<Space
android:layout_width="match_parent"
android:layout_height="@dimen/divider_normal" />
<Button
android:id="@+id/btnEditProfile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/btn_gradient_blue"
android:paddingStart="48dp"
android:paddingEnd="48dp"
android:text="Edit Profile"
android:textAllCaps="false"
android:textColor="@android:color/white" />
<!--
DO NOT CHANGE,
CHANGE ONLY IF TOOLBAR SIZE (FOR TAB_LAYOUT) IS ALSO CHANGED
-->
<Space
android:layout_width="match_parent"
android:layout_height="56dp" />
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
app:layout_collapseMode="pin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.design.widget.TabLayout
android:id="@+id/tabsProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
app:tabBackground="@null"
app:tabGravity="center"
app:tabIndicatorColor="@android:color/white"
app:tabIndicatorHeight="2dp">
<android.support.design.widget.TabItem
android:id="@+id/tabProfileMySSSS"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<android.support.design.widget.TabItem
android:id="@+id/tabProfileMySSSSS"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.design.widget.TabLayout>
<ImageButton
android:id="@+id/ibtnProfileTimelineRefresh"
android:layout_width="128dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_marginRight="@dimen/divider_normal"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_autorenew_white_24dp" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
which is inside a CoordinatorLayout
and the ff layout for the TimelineFragment
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="92dp">
<android.support.design.widget.AppBarLayout
android:fitsSystemWindows="true"
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/cvCreateSSSSS"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/divider_small"
android:layout_marginRight="@dimen/divider_small"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="8dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="@dimen/divider_normal">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/svg_nav_create_SSSSSS" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="@dimen/divider_normal"
android:text="What's on your mind?"
android:textColor="@android:color/black"
android:textSize="@dimen/text_content" />
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="@dimen/divider_xsmall"
android:src="@drawable/svg_insert_image" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:visibility="gone">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<...some other layouts />
</android.support.design.widget.CoordinatorLayout>
For visuals on what my issue is
** This image is from the ProfileFragment
The extra space which I marked red has not existed before, when I still haven't added the AppBarLayout
(containing the toolbar) on the TimelineFragment
.
I have tried removing the whole AppBarLayout
on the TimelineFragment
, and it does fix the weird extra space on the ProfileFragment
. Why is it that there is a relation between these fragments when they do not share anything besides being in the same ViewPager
?
How do I remove the space that I marked red on the image? It might be related to the toolbar since it is same in color. The AppBarLayout
uses a lighter color than the toolbar.
android android-layout android-viewpager android-toolbar android-collapsingtoolbarlayout
I have a collapsing toolbar in my TimelineFragment
which I recently added. And there is an already existing collapsing toolbar which previously worked fine in my ProfileFragment
until when I added the similar toolbar to the TimelineFragment
. Both of these fragments are contained in a view pager.
I have the ff layout for the ProfileFragment
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/ivProfileAvatar"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/divider_small"
android:src="@drawable/profile_image" />
<Space
android:layout_width="match_parent"
android:layout_height="@dimen/divider_small" />
<TextView
android:id="@+id/tvUserUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="JuanOne"
android:textColor="@android:color/white"
android:textSize="@dimen/text_header"
android:textStyle="bold" />
<TextView
android:id="@+id/tvUserCommunity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="University Name"
android:textColor="@android:color/white"
android:textSize="@dimen/text_content" />
<TextView
android:id="@+id/tvUserBio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Still learning to face difficulty"
android:textColor="@android:color/white"
android:textSize="@dimen/text_content" />
<Space
android:layout_width="match_parent"
android:layout_height="@dimen/divider_normal" />
<Button
android:id="@+id/btnEditProfile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/btn_gradient_blue"
android:paddingStart="48dp"
android:paddingEnd="48dp"
android:text="Edit Profile"
android:textAllCaps="false"
android:textColor="@android:color/white" />
<!--
DO NOT CHANGE,
CHANGE ONLY IF TOOLBAR SIZE (FOR TAB_LAYOUT) IS ALSO CHANGED
-->
<Space
android:layout_width="match_parent"
android:layout_height="56dp" />
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
app:layout_collapseMode="pin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.design.widget.TabLayout
android:id="@+id/tabsProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
app:tabBackground="@null"
app:tabGravity="center"
app:tabIndicatorColor="@android:color/white"
app:tabIndicatorHeight="2dp">
<android.support.design.widget.TabItem
android:id="@+id/tabProfileMySSSS"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<android.support.design.widget.TabItem
android:id="@+id/tabProfileMySSSSS"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.design.widget.TabLayout>
<ImageButton
android:id="@+id/ibtnProfileTimelineRefresh"
android:layout_width="128dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_marginRight="@dimen/divider_normal"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_autorenew_white_24dp" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
which is inside a CoordinatorLayout
and the ff layout for the TimelineFragment
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="92dp">
<android.support.design.widget.AppBarLayout
android:fitsSystemWindows="true"
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/cvCreateSSSSS"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/divider_small"
android:layout_marginRight="@dimen/divider_small"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="8dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="@dimen/divider_normal">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/svg_nav_create_SSSSSS" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="@dimen/divider_normal"
android:text="What's on your mind?"
android:textColor="@android:color/black"
android:textSize="@dimen/text_content" />
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="@dimen/divider_xsmall"
android:src="@drawable/svg_insert_image" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:visibility="gone">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<...some other layouts />
</android.support.design.widget.CoordinatorLayout>
For visuals on what my issue is
** This image is from the ProfileFragment
The extra space which I marked red has not existed before, when I still haven't added the AppBarLayout
(containing the toolbar) on the TimelineFragment
.
I have tried removing the whole AppBarLayout
on the TimelineFragment
, and it does fix the weird extra space on the ProfileFragment
. Why is it that there is a relation between these fragments when they do not share anything besides being in the same ViewPager
?
How do I remove the space that I marked red on the image? It might be related to the toolbar since it is same in color. The AppBarLayout
uses a lighter color than the toolbar.
android android-layout android-viewpager android-toolbar android-collapsingtoolbarlayout
android android-layout android-viewpager android-toolbar android-collapsingtoolbarlayout
edited Jan 3 at 18:41
Rick
asked Jan 3 at 18:32
RickRick
10710
10710
you are using android:layout_marginTop="92dp" in your CoordinatorLayout tag remove this and check
– Imtiaz Abir
Jan 4 at 5:26
and also you can use these propertiees in Coordinator layout: android:layout_height="0dp" android:layout_weight="1" android:fitsSystemWindows="true"
– Imtiaz Abir
Jan 4 at 5:31
add a comment |
you are using android:layout_marginTop="92dp" in your CoordinatorLayout tag remove this and check
– Imtiaz Abir
Jan 4 at 5:26
and also you can use these propertiees in Coordinator layout: android:layout_height="0dp" android:layout_weight="1" android:fitsSystemWindows="true"
– Imtiaz Abir
Jan 4 at 5:31
you are using android:layout_marginTop="92dp" in your CoordinatorLayout tag remove this and check
– Imtiaz Abir
Jan 4 at 5:26
you are using android:layout_marginTop="92dp" in your CoordinatorLayout tag remove this and check
– Imtiaz Abir
Jan 4 at 5:26
and also you can use these propertiees in Coordinator layout: android:layout_height="0dp" android:layout_weight="1" android:fitsSystemWindows="true"
– Imtiaz Abir
Jan 4 at 5:31
and also you can use these propertiees in Coordinator layout: android:layout_height="0dp" android:layout_weight="1" android:fitsSystemWindows="true"
– Imtiaz Abir
Jan 4 at 5:31
add a comment |
1 Answer
1
active
oldest
votes
I have already fixed it. Apparently, the Activity that was holding all these fragments is using coordinator layout. So I removed that, and that space was gone. I believe that using a toolbar inside these fragments made the activity holding them create a toolbar on its own.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54027905%2fhow-do-i-correctly-implement-toolbars-inside-fragments-in-viewpager%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I have already fixed it. Apparently, the Activity that was holding all these fragments is using coordinator layout. So I removed that, and that space was gone. I believe that using a toolbar inside these fragments made the activity holding them create a toolbar on its own.
add a comment |
I have already fixed it. Apparently, the Activity that was holding all these fragments is using coordinator layout. So I removed that, and that space was gone. I believe that using a toolbar inside these fragments made the activity holding them create a toolbar on its own.
add a comment |
I have already fixed it. Apparently, the Activity that was holding all these fragments is using coordinator layout. So I removed that, and that space was gone. I believe that using a toolbar inside these fragments made the activity holding them create a toolbar on its own.
I have already fixed it. Apparently, the Activity that was holding all these fragments is using coordinator layout. So I removed that, and that space was gone. I believe that using a toolbar inside these fragments made the activity holding them create a toolbar on its own.
answered Jan 5 at 3:20
RickRick
10710
10710
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54027905%2fhow-do-i-correctly-implement-toolbars-inside-fragments-in-viewpager%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you are using android:layout_marginTop="92dp" in your CoordinatorLayout tag remove this and check
– Imtiaz Abir
Jan 4 at 5:26
and also you can use these propertiees in Coordinator layout: android:layout_height="0dp" android:layout_weight="1" android:fitsSystemWindows="true"
– Imtiaz Abir
Jan 4 at 5:31