0

I'm using a pull to refresh library, which I know is deprecated, but unfortunately the client I'm working for is reluctant to change it so I'm unable to do so.

I'm using this library from @ChrisBanes: https://github.com/chrisbanes/ActionBar-PullToRefresh

In my home activity layout I have a navigation drawer

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white" >

The problem I have is that no matter what I do, the layout that gets added to the view hierarchy for the pull to refresh functionality always gets drawn on top of everything else, so that includes the navigation drawer, so whenever you have the drawer open and a refresh is going on, you always have the progress bar and the pull to refresh layout drawing on top of my navigation drawer layout.

I have been going though the code and I noticed that the layout gets added like this:

// Create LayoutParams for adding the View as a panel
WindowManager.LayoutParams wlp = new WindowManager.LayoutParams(width, height,
    WindowManager.LayoutParams.TYPE_APPLICATION_PANEL,
    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
    PixelFormat.TRANSLUCENT);
wlp.x = 0;
wlp.y = mRect.top;
wlp.gravity = Gravity.TOP;

// Workaround for Issue #182
headerView.setTag(wlp);

mActivity.getWindowManager().addView(headerView, wlp);

I haven't really got a complete understanding of how the window manager works, but I'm not sure if the layout should be added to another view or if there is another property I'm missing that would allow me to modify the z-index of this layout, and unfortunately I'm even unable to see this layout on hierarchy viewer.

I would really appreciate any help on this matter as I have been struggling with this for a couple of days without being able to solve it.

Thanks in advance.

injektilo
  • 25
  • 1
  • 4
  • Maybe it is kind of a library glitch. Have you tried it with the official PullToRefresh library? https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html – droidpl Apr 14 '15 at 20:03
  • Thanks for your quick answer. Unfortunately my client doesn't want to change the library so I'm unable to change it and I must find a way to solve this using this library. – injektilo Apr 14 '15 at 20:06
  • Uff, think it is the libray itself, not something related to z-index which is not relevant in Android (until lollipop). I am not an expert on Windows, but your problem sounds to me that the DrawerLayout is not moving your pullToRefresh with it, probably related to an onDraw implementation glitch. Its kind of an intuition, I am so sorry. – droidpl Apr 14 '15 at 20:14
  • No worries man. Thanks a lot for your quick answers. I'll continue to play with the code. I'm hoping @ChrisBanes who wrote the library could maybe help me out. – injektilo Apr 14 '15 at 20:22
  • Sure, but take into account it is not longer until development, so maybe he will not solve your problems. – droidpl Apr 14 '15 at 20:23

0 Answers0