Search code examples
androidandroid-recyclerviewandroid-imageviewandroid-relativelayout

ImageView doesn't shows above the recyclerView in same parent Layout


<RelativeLayout
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:paddingTop="5dip">

<android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/rv_activity"
    android:elevation="2dp"
   android:stateListAnimator="@drawable/translation_selector"
    android:clickable="true">

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

<ImageView
    android:id="@+id/iv_down"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
   android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:src="@drawable/ic_down"
    android:visibility="visible"
    android:padding="5dp"
    android:alpha="0.8"
    android:background="@drawable/circular_dk_grey_bg"
    android:layout_marginRight="20dp"
    android:layout_marginBottom="20dp"
    />

</RelativeLayout>

This is my code. My imageView ivDown is not visible as the recylerView is overlapping. The image is not appearing on the screen, but all the elements for recyclerView adapter are getting displayed. In the layout xml, the ivDown is visble, but after setting the adapter on my device it's not visible. What should I do in this case??


Solution

  • Remove android:elevation="2dp" on Recylerview , which might cause your Recycler to overlap imageview.

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/rv_activity"
       android:stateListAnimator="@drawable/translation_selector"
        android:clickable="true"/>
    
    <ImageView
        android:id="@+id/iv_down"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/ic_down"
        android:visibility="visible"
        android:padding="5dp"
        android:elevation="4dp"
        android:alpha="0.8"
        android:background="@drawable/circular_dk_grey_bg"
        android:layout_marginRight="20dp"
        android:layout_marginBottom="20dp"
        />