0

my XML :

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical">

<ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/progressBar"
    android:layout_gravity="center_horizontal|top"
    android:layout_marginTop="50dp"
    android:indeterminate="true"
    android:visibility="invisible"
    android:layout_centerHorizontal="true" />

    <android.support.v7.widget.Toolbar
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:id="@+id/toolbarTab2"
        app:theme="@style/ToolBarStyle"
        android:elevation="5dp"
        android:paddingTop="20dp"
        android:textAlignment="center"
        android:background="@android:color/holo_red_light">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="MY TOOLBAR TITLE"
            android:layout_gravity="center"
            android:id="@+id/toolbar_title"
            android:textSize="20sp"
            android:textStyle="bold"
            android:background="#00000000"
            android:textColor="#ffffff" />

    </android.support.v7.widget.Toolbar>


    <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipe_refresh_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:foregroundGravity="left|right">




    <android.support.v7.widget.RecyclerView

        android:id="@+id/notesList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"

        >

    </android.support.v7.widget.RecyclerView>


</android.support.v4.widget.SwipeRefreshLayout>

</RelativeLayout>

my toolbar is working fine on api 21 and higher because of Elevation but on api <20 its covered by Activity's element (since they dont support elevation ) , any idea how to fix this ??

here you can see that my toolbar is behind the cardview enter image description here

remy boys
  • 2,928
  • 5
  • 36
  • 65

1 Answers1

1
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical">

<ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/progressBar"
    android:layout_gravity="center_horizontal|top"
    android:layout_marginTop="50dp"
    android:indeterminate="true"
    android:visibility="invisible"
    android:layout_centerHorizontal="true" />

<android.support.v7.widget.Toolbar
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:minHeight="?attr/actionBarSize"
    android:id="@+id/toolbarTab2"
    app:theme="@style/ToolBarStyle"
    android:elevation="5dp"
    android:paddingTop="20dp"
    android:textAlignment="center"
    android:background="@android:color/holo_red_light">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="MY TOOLBAR TITLE"
        android:layout_gravity="center"
        android:id="@+id/toolbar_title"
        android:textSize="20sp"
        android:textStyle="bold"
        android:background="#00000000"
        android:textColor="#ffffff" />

</android.support.v7.widget.Toolbar>


<android.support.v4.widget.SwipeRefreshLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipe_refresh_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="?attr/actionBarSize" 
    android:clipToPadding="false"
    android:clipChildren="false"
    android:foregroundGravity="left|right">

<android.support.v7.widget.RecyclerView
    android:id="@+id/notesList"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"

    >

</android.support.v7.widget.RecyclerView>


</android.support.v4.widget.SwipeRefreshLayout>

</RelativeLayout>
Harry
  • 1,151
  • 11
  • 27
  • thanks for responding man , its working but i want to overlay content , right now my other contents are below of toolbar , i want to overlay other content with my toolbar because am making visible and transparent according to scroll of RecyclerView – remy boys Jul 02 '16 at 17:35
  • are you saying that you want to hide/show your toolbar with respect to the scroll of your recycler view? – Harry Jul 02 '16 at 17:45
  • no i'm already doing that see this https://raw.githubusercontent.com/kanytu/android-parallax-recycleview/master/screenshots/parallaxtoolbar.gif like this – remy boys Jul 02 '16 at 17:46
  • I have edited my answer and see if that helps you but I'm not completely sure about it. However what you are trying to achieve can be easily done using the support library. See this link on how to do this https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout – Harry Jul 02 '16 at 18:00
  • well your updated answer is doing exactly opposite of what i want now i have an extra space between my layout and toolbar , can i add this padding with (- number) ? – remy boys Jul 02 '16 at 18:05
  • did you remove lines added from the previous answer? – Harry Jul 02 '16 at 18:08
  • can we add negative Padding @harry ? – remy boys Jul 02 '16 at 18:18
  • @remy boys Ok, now see if it works now. It is working from my end. – Harry Jul 02 '16 at 18:34