RecyclerView with NestedScrollView - android

I am developing an android music player where I have album detail activity with collapsing toolbar and nested scroll view. Inside nested scrollview there are three textviews and a recyclerview see the code below,
<android.support.v4.widget.NestedScrollView
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/linear_detail_background"
app:behavior_overlapTop="50dp"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/album_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:paddingLeft="10dp"
android:maxLines="1"
android:ellipsize="end"
android:text="Album Name"
android:textSize="24dp"
android:textColor="#000"
/>
<TextView
android:id="#+id/album_artist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Album Name"
android:textSize="14dp"
android:paddingLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="15dp"
android:maxLines="1"
android:ellipsize="end"
/>
<TextView
android:id="#+id/song_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Songs"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Body1"
android:paddingLeft="10dp"
android:layout_marginTop="5dp"
android:textColor="#000"
/>
<android.support.v7.widget.RecyclerView
android:nestedScrollingEnabled="false"
android:id="#+id/album_songs"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
The above code results in this Image
The problem occurs when there are more songs, the image above shows the album name This Party Gettin Hot and the Artist name. But when there are more songs the Album name and the artist name is not showing.
See this Image for Problem
The Complete XML code is as Below
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:background="#color/white"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_albums_songs"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="#color/white"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/poster"
android:layout_width="match_parent"
android:layout_height="300dp"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
android:background="#drawable/gradient_bg"/>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_album_detail"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/linear_detail_background"
app:behavior_overlapTop="50dp"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/album_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:paddingLeft="10dp"
android:maxLines="1"
android:ellipsize="end"
android:text="Album Name"
android:textSize="24dp"
android:textColor="#000"
/>
<TextView
android:id="#+id/album_artist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Album Name"
android:textSize="14dp"
android:paddingLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="15dp"
android:maxLines="1"
android:ellipsize="end"
/>
<TextView
android:id="#+id/song_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Songs"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Body1"
android:paddingLeft="10dp"
android:layout_marginTop="5dp"
android:textColor="#000"
/>
<android.support.v7.widget.RecyclerView
android:nestedScrollingEnabled="false"
android:id="#+id/album_songs"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
how can I solve this issue? What I am doing wrong?

try change your nested scroll view layout_width to wrap content
<android.support.v4.widget.NestedScrollView
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/linear_detail_background"
app:behavior_overlapTop="50dp"
>

Related

Make nested scrollview not scroll completely

In my activity XML I have a Collapsing toolbar and, after that, an referring to my other XML where I have a NestedScrollView.
This is an image of the collapsing toolbar when it is NOT collapsed.
When I scroll up, it becomes collapsed and the NestedSrollView appears like this:
I want it to scroll just to some point like this and after that the user cannot scroll more:
How can I achieve this?
This is my main XML:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/relLayoutCountryInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_anchor="#+id/testeparadetail"
app:layout_anchorGravity="bottom">
<android.support.design.widget.AppBarLayout
android:id="#+id/testeparadetail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/actionBarDivider"
app:layout_anchor="#+id/testeparadetail"
app:layout_anchorGravity="bottom">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/backgroundcollapsedtoolbardetail"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="exitUntilCollapsed|scroll">
<ImageView
android:id="#+id/imgPhotoDetailFundo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<ImageView
android:id="#+id/imgPhotoDetailEscuro"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="#drawable/background_pais_info"
android:scaleType="centerInside" />
<ImageView
android:id="#+id/imgEscuroPhotoDetailTopo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cropToPadding="false"
android:scaleX="2"
android:scaleY="-1"
app:srcCompat="#drawable/blur_paises_filtro" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbariddetail"
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<com.github.mmin18.widget.RealtimeBlurView
android:id="#+id/blurViewDetail"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:realtimeBlurRadius="10dp"
app:realtimeOverlayColor="#8000" />
<TextView
android:id="#+id/txtNomePaisDetail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="30dp"
android:layout_marginTop="520dp"
android:paddingBottom="40dp"
android:text="TextView"
android:textColor="#android:color/background_light"
android:textSize="35sp"
app:layout_anchor="#+id/txtNomeContinente"
app:layout_anchorGravity="left|bottom" />
<TextView
android:id="#+id/txtDefinicao"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="30dp"
android:layout_marginTop="520dp"
android:paddingBottom="10dp"
android:text="TextView"
android:textColor="#android:color/background_light"
android:textSize="25sp"
app:layout_anchor="#+id/testeparainfo"
app:layout_anchorGravity="left|bottom" />
<ImageView
android:id="#+id/imgVoltarPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
app:srcCompat="#drawable/arrow_back_branca" />
<ImageView
android:id="#+id/imgApagarPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="355dp"
android:layout_marginTop="550dp"
android:paddingBottom="40dp"
app:layout_anchor="#+id/txtDefinicao"
app:layout_anchorGravity="right|bottom"
app:srcCompat="#android:drawable/ic_menu_delete" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include
layout="#layout/content_scrolling_photo_detail"
/>
And this is my include
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="30dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
Add this line to NestedScrollView Child... See my below code as an example...
android:nestedScrollingEnabled="true"
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/tablayout"
android:layout_marginTop="2dp"
android:nestedScrollingEnabled="true"/> // add this line to NestedScrollView child
</android.support.v4.widget.NestedScrollView>

Scrolling issue with RecyclerView in CoordinatorLayout

I have issue with scrolling in my code .. here is my xml :-
<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:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#color/colorThemeDark"
android:fitsSystemWindows="true"
android:stateListAnimator="#drawable/appbar_always_elevated"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:collapsedTitleGravity="left"
app:contentScrim="#color/colorThemeDark"
app:expandedTitleGravity="center|bottom"
app:expandedTitleTextAppearance="#style/ExpandedAppBar"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/circleView"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerHorizontal="true"
android:layout_gravity="center_vertical|center_horizontal"
android:src="#drawable/main_logo"
app:layout_collapseMode="none" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#323642"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout
android:id="#+id/firstText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:paddingLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="What you learn today?"
android:textColor="#color/colorWhite"
android:textStyle="bold" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/catBoxes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/firstText"
android:layout_marginTop="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
<RelativeLayout
android:id="#+id/secondText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/catBoxes"
android:paddingLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Recommended for you"
android:textColor="#color/colorWhite"
android:textStyle="bold" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/catMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/secondText"
android:layout_marginTop="5dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior" </android.support.v7.widget.RecyclerView>
</RelativeLayout></android.support.design.widget.CoordinatorLayout>
I have two different recyclerView in single Activity.as in my code , i take root element as CoordinatorLayout. i add two RecyclerView in my code.when i scroll my recyclerview it scroll only first recyclerView and second RecyclerView scroll below first recyclerview. but i want to both recyclerView scroll at same time when i scroll up my screen.
Gif with my problem. Green boxes scrolled but i want to stop this green boxes scrolling
When you have two recycler view in a view and you want them to use all the space, you need to use NestedScrollView.
Your code will be the following:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#323642"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout
android:id="#+id/firstText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:paddingLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="What you learn today?"
android:textColor="#color/colorWhite"
android:textStyle="bold" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/catBoxes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/firstText"
android:layout_marginTop="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
<RelativeLayout
android:id="#+id/secondText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/catBoxes"
android:paddingLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Recommended for you"
android:textColor="#color/colorWhite"
android:textStyle="bold" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/catMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/secondText"
android:layout_marginTop="5dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
And in your code, use this in both recycler view:
LayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setAutoMeasureEnabled(true);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setNestedScrollingEnabled(false);
More info in smbd uknow`s answer here

Issue with collapsing toolbar in marshmallow and above

I am facing a little issue with Collapsing toolbar and only for the devices having OS marshmallow and above, for lower versions its working fine
following is my layout
<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:background="#color/fp_dashboard_backgrd"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/transparent"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|enterAlways">
<include
layout="#layout/filter_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="#+id/MyToolbar"
android:layout_width="match_parent"
android:background="#color/fund_screener_toolbar"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:theme="#style/ActionBar">
<TextView
android:id="#+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:maxLines="1"
android:text=" Fund Screener "
android:textColor="#color/color_white"
android:textSize="#dimen/dimen_txt_20" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include
android:id="#+id/scrolll"
layout="#layout/recycle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:clipToPadding="false"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<include
android:id="#+id/imageViewProgress"
layout="#layout/layout_bull_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</android.support.design.widget.CoordinatorLayout>
And here are the first image showing when i scroll up
and when i scroll down i get this extra white space above my toolbar I am not sure what is going wrong. check below image. As you guys can see white space above my Fund Screener toolbar
Guys please help me I have done lot of changes and research but not able to get any solution. Please help
EDIT
filter_search.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="vertical"
android:padding="10dp">
<android.support.v7.widget.AppCompatSpinner
android:id="#+id/spnAMCName"
style="#style/Base.Widget.AppCompat.Spinner.Underlined"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/SpinnerBottomLine" />
<com.app.widgets.TextViewRobotoRegular
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="#string/lbl_asset_type"
android:textColor="#color/fp_light_gray"
android:textSize="13sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<com.app.widgets.TextViewRobotoLight
android:id="#+id/btnequity"
android:layout_width="#dimen/dimen_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/btn_border_default"
android:gravity="center"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:text="#string/equity"
android:textColor="#color/fp_light_gray"
android:textSize="13sp" />
<com.app.widgets.TextViewRobotoLight
android:id="#+id/btndebt"
android:layout_width="#dimen/dimen_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/btn_border_default"
android:gravity="center"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:text="#string/debt"
android:textColor="#color/fp_light_gray"
android:textSize="13sp" />
<com.app.widgets.TextViewRobotoLight
android:id="#+id/btnhybrid"
android:layout_width="#dimen/dimen_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/btn_border_default"
android:gravity="center"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:text="#string/hybrid"
android:textColor="#color/fp_light_gray"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:weightSum="1">
<android.support.v7.widget.AppCompatSpinner
android:id="#+id/spnFundSubCategory"
style="#style/Base.Widget.AppCompat.Spinner.Underlined"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_weight="0.5"
android:paddingRight="2dp"
android:theme="#style/SpinnerBottomLine" />
<android.support.v7.widget.AppCompatSpinner
android:id="#+id/spnFundNature"
style="#style/Base.Widget.AppCompat.Spinner.Underlined"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_weight="0.5"
android:paddingLeft="2dp"
android:theme="#style/SpinnerBottomLine" />
</LinearLayout>
</LinearLayout>
You are using android:layout_marginTop="?attr/actionBarSize" where you are including your layout="#layout/filter_search". This is causing actionBarSize space above your CollapsingToolbarLayout in expanded mode. Just remove it as follows.
<include
layout="#layout/filter_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
I hope this works for you.Thank You

The Whole DrawerLayout is scrollable

I am trying to read the layout code but couldn't get why.
I have a code for drawerlayout and the problem is the whole drawerLayout is scroll able i just want to the items list view scroll able not the header and i couldn't figure it out because it looks like all components are custom made.
Can any one have a look at it..
Thanks in advance
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.activities.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
style="#style/ToolBarStyle"
android:layout_width="match_parent"
android:layout_height="#dimen/abc_action_bar_default_height_material"
android:background="?attr/colorPrimary">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="#dimen/abc_action_bar_default_height_material">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:src="#drawable/menu_logo" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<ViewFlipper
android:id="#+id/loading_switcher"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/checkout_container">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="vertical"
android:padding="10dp"
app:layout_scrollFlags="scroll|enterAlways">
<com.views.font.CustomFontTextView
android:id="#+id/location_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_location_on_black_18dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:singleLine="true"
android:text="Pick Location"
android:textColor="#color/colorPrimary"
android:textSize="15sp" />
<com.views.font.CustomFontTextView
android:id="#+id/locality_info_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:singleLine="true"
android:textColor="#android:color/black"
android:textSize="12sp" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/product_list_swipe_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp">
<android.support.v7.widget.RecyclerView
android:id="#+id/products_list_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
<com.views.CheckoutShelfView
android:id="#+id/checkout_container"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentBottom="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<com.views.font.CustomFontTextView
android:id="#+id/error_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="center"
android:textColor="#color/grey_bg"
android:textSize="20sp" />
<com.views.font.CustomFontTextView
android:id="#+id/error_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#drawable/shape_green_fill_round_5dp"
android:drawablePadding="2dp"
android:gravity="center_vertical"
android:paddingBottom="5dp"
android:paddingLeft="4dp"
android:paddingRight="8dp"
android:paddingTop="5dp"
android:textAllCaps="false"
android:textColor="#android:color/white" />
</LinearLayout>
</ViewFlipper>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/header_navigation"
app:itemIconTint="#color/colorPrimary"
app:itemTextColor="#color/colorPrimary"
app:menu="#menu/navigation_menu">
<com.views.font.CustomFontTextView
android:id="#+id/version_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:background="#android:color/white"
android:gravity="center"
android:padding="3dp"
android:textSize="10sp">
</com.views.font.CustomFontTextView>
</android.support.design.widget.NavigationView>
</ScrollView>
</android.support.v4.widget.DrawerLayout>
try this:
Remove Scrollview from the layout:
try this:
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/header_navigation"
app:itemIconTint="#color/colorPrimary"
app:itemTextColor="#color/colorPrimary"
app:menu="#menu/navigation_menu" />
In activity;
//mNavigationView is your navigation view
mNavViewHeaderLayout = LayoutInflater.from(MainActivity.this).inflate(R.layout.header_navigation, mNavigationView);
//to access content in header view
mTextview = (TextView)mNavViewHeaderLayout.findViewById(R.id.textview);

How to implement soundcloud header layout for profile

how to implement above layout using mostly the fact that the toolbar doesn't move while the image under it slide up and down, i want achieve the same effect ,am currently implementing using the new cordinatorlayout and collapsing toolbar and Relative layout containing and image
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.madiba.listmulti.TabbedActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
app:titleEnabled="false"
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/banner"
android:fitsSystemWindows="true"
android:src="#android:color/holo_red_light"
android:layout_width="match_parent"
android:layout_height="180dp" />
<LinearLayout
android:layout_alignParentRight="true"
android:orientation="vertical"
android:padding="10dp"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="Follow"
android:textColor="#android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:id="#+id/main_title"
android:layout_below="#id/banner"
android:gravity="center"
android:textColor="#android:color/black"
android:paddingTop="12dp"
android:paddingBottom="8dp"
android:textStyle="bold"
android:text="Flume Concert"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:layout_below="#id/main_title"
android:orientation="horizontal"
android:paddingBottom="8dp"
android:layout_gravity="center"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#android:color/darker_gray"
android:text="12 event | "
android:textAppearance="#style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:textColor="#android:color/darker_gray"
android:text="4 members "
android:textAppearance="#style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
<TextView
android:gravity="center"
android:textColor="#android:color/black"
android:paddingTop="12dp"
android:paddingBottom="8dp"
android:textStyle="bold"
android:text="Flume Concert"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!--</LinearLayout>-->
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
app:tabSelectedTextColor="#android:color/black"
app:tabTextColor="#android:color/darker_gray"
android:background="#android:color/white"
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>

Categories

Resources