android - How can I stop this ProgressBar from being scrolled along with the toolbar? -


is there way stop progressbar being scrolled , down along toolbars? right have 2 toolbars supposed scrolled , down when there items in recyclerview, problem scrolling behaviour affecting layout below toolbar when there aren't results show. take look:

gif showing behaviour

needless say, progressbar shouldn't scrolled under circumstances. layouts:

activity_base.xml

<android.support.v4.widget.drawerlayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:id="@+id/drawerlayout"     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.support.design.widget.appbarlayout             android:id="@+id/appbarlayout"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:theme="@style/themeoverlay.appcompat.dark.actionbar">              <android.support.v7.widget.toolbar                 android:id="@+id/toolbar"                 android:layout_width="match_parent"                 android:layout_height="64dp"                 android:minheight="64dp"                 android:theme="@style/themeoverlay.appcompat.dark.actionbar"                 app:layout_scrollflags="scroll|enteralways|snap"                 app:popuptheme="@style/themeoverlay.appcompat.light" />              <android.support.v7.widget.toolbar                 android:id="@+id/toolbarbottom"                 android:layout_width="match_parent"                 android:layout_height="64dp"                 android:minheight="64dp"                 android:theme="@style/themeoverlay.appcompat.dark.actionbar"                 android:layout_gravity="bottom"                 app:layout_scrollflags="scroll|enteralways|snap"                 app:popuptheme="@style/themeoverlay.appcompat.light"                 android:visibility="visible">                  <linearlayout                     android:layout_width="match_parent"                     android:layout_height="match_parent">                     <spinner                         android:id="@+id/spinner_sites"                         android:layout_width="0dp"                         android:layout_height="match_parent"                         android:layout_weight="1" />                     <spinner                         android:id="@+id/spinner_sort_field"                         android:layout_width="0dp"                         android:layout_height="match_parent"                         android:layout_weight="1" />                     <spinner                         android:id="@+id/spinner_sort_order"                         android:layout_width="0dp"                         android:layout_height="match_parent"                         android:layout_weight="1" />                  </linearlayout>             </android.support.v7.widget.toolbar>          </android.support.design.widget.appbarlayout>          <include layout="@layout/activity_masterdetail"/>          <view             android:id="@+id/view_search_tint"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:alpha="0.0"             android:background="#88000000"             android:elevation="2dp"             android:layertype="hardware"             android:visibility="gone" />          <org.cryse.widget.persistentsearch.persistentsearchview             android:id="@+id/searchview"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_alignparenttop="true"             android:elevation="4dp"             app:persistentsv_logostring="@string/app_name"             app:persistentsv_searchtextcolor="?android:textcolorprimary"             app:persistentsv_edittextcolor="?android:textcolorprimary"             app:persistentsv_edithinttext="search"             app:persistentsv_edithinttextcolor="?android:textcolorhint"             app:persistentsv_displaymode="toolbar"             app:persistentsv_homebuttonmode="burger"             app:persistentsv_searchcardelevation="2dp"             app:persistentsv_customtoolbarheight="64dp"             app:layout_behavior=".scrollingsearchviewbehavior"/>     </android.support.design.widget.coordinatorlayout> </android.support.v4.widget.drawerlayout> 

the include <include layout="@layout/activity_masterdetail"/> ref points activity_fragment.xml:

<framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/fragment_list" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 

the fragment_list.xml

<relativelayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent">      <android.support.v7.widget.recyclerview         android:id="@+id/recycler_view_list"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:visibility="visible"/>      <!-- include pogress bar-->     <include         android:id="@+id/progress_bar"         layout="@layout/progress_bar"         android:visibility="gone" />  </relativelayout> 

the progress_bar regular, run of mill progressbar now:

<progressbar xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.wrap_content.com/apk/res-auto"     android:id="@+id/pbloading"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_centerinparent="true"     android:visibility="invisible"/> 

as can see other searchview layout standard don't know why issue happening. i've found removing app:layout_behavior="@string/appbar_scrolling_view_behavior" activity_fragment.xml stops issue happening recyclerview isn't aligned toolbar , results appear on screen, covering toolbar , all. that's not want happen.

marking recyclerview's visibility 'gone' stops scrolling of progressbar same it's not being centralized, meaning issue still there can't scroll screen. setting android:fitssystemwindows="true" attribute in every container didn't work. i've tried tweaking layout attributes think of no luck, appreciated.

it seems i'll have post answer own question, it's more of workaround works. i'll waiting "actual" answer , mark such whenever it's posted.

what have remove app:layout_behavior="@string/appbar_scrolling_view_behavior" attribute activity_fragment.xml , add programatically after progressbar has been hidden away setvisibility(view.gone). have make sure removed whenever you're going show progressbar again. can done in asynctask's onpostexecute() , onpreexecute() methods. need keep reference @+id/fragment_list fragment. here code:

view parent; public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) {     // keeping reference @+id/fragment_list fragment     parent = container;     // other code     task = new searchresultstask();     task.execute();     return view; } 

and on searchresultstask asynctask:

@override protected void onpostexecute(list s) {     super.onpostexecute(s);     adapter.adds(s);      progressbar.setvisibility(view.gone);      coordinatorlayout.layoutparams params =     (coordinatorlayout.layoutparams) parent.getlayoutparams();     // adding behaviour programatically     params.setbehavior(new appbarlayout.scrollingviewbehavior());     parent.requestlayout();      rvlist.setvisibility(view.visible); }  @override protected void onpreexecute() {     super.onpreexecute();      coordinatorlayout.layoutparams params =     (coordinatorlayout.layoutparams) parent.getlayoutparams();     // removing behaviour     params.setbehavior(null);     parent.requestlayout();      progressbar.setvisibility(view.visible); } 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -