0

I have a recylerview in books.xml file where I am showing some regular book records as a list. What I am trying is to include books.xml file in activity_main.xml file to show the books record in home window. I need to show this records as a overlay window over main activity window as user can scroll them vertically to see the whole records. Looking like below image enter image description here

And this is my current activity_main.xml file. How can I achieve same result

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/activity_main"
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"
tools:context="com.trioangle.goferdriver.MainActivity"
android:keepScreenOn="true">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="@color/colorblock"
    android:id="@+id/relativeLayout2">
    <ImageView
        android:visibility="gone"
        android:id="@+id/homelist"
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:padding="12dp"
        android:layout_centerVertical="true"
        android:src="@drawable/list"
        android:tint="@color/white"/>
    <View
        android:visibility="gone"
        android:id="@+id/view"
        android:layout_width="1dp"
        android:layout_height="match_parent"
        android:layout_toRightOf="@+id/homelist"
        android:background="@color/button_material_light"
        android:layout_marginLeft="5dp"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"/>
    <com.trioangle.goferdriver.custompalette.FontTextView
        android:id="@+id/txt_driverstatus"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/offline"
        android:paddingLeft="20dp"
        android:layout_centerVertical="true"
        android:textSize="18sp"
        android:textColor="@color/white"
        app:font="@string/font_UBERMedium"
        android:layout_toRightOf="@+id/homelist"
        />

    <android.support.v7.widget.SwitchCompat
        style="@style/SwitchCompatStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/switch_driverstatus"
        android:layout_alignParentRight="true"
        android:layout_marginRight="20dp"
        android:checked="false"
        android:layout_centerVertical="true"/>

    <com.trioangle.goferdriver.custompalette.FontTextView
        android:visibility="gone"
        android:background="@color/ub__red"
        android:id="@+id/txt_checkdriverstatus"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/checkstatus"
        android:layout_alignParentRight="true"
        android:layout_marginRight="20dp"
        android:layout_centerVertical="true"
        android:textSize="18sp"
        android:padding="5dp"
        android:textColor="@color/white"
        app:font="@string/font_UBERMedium"
        />
</RelativeLayout>

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/relativeLayout2">

    <TextView
        android:id="@+id/iv_line"
        android:layout_width="50dp"
        android:layout_height="5dp"
        android:background="#ffffff"/>

</RelativeLayout>

<FrameLayout
    android:id="@+id/frame_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/navigation"
    android:layout_below="@+id/relativeLayout2">
</FrameLayout>

<android.support.design.widget.BottomNavigationView
    android:paddingTop="5dp"
    android:paddingBottom="5dp"
    android:layout_centerVertical="true"
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="@color/colorblock"
    app:itemIconTint="@color/nav_item_state_list"
    app:itemTextColor="@color/nav_item_state_list"
    app:menu="@menu/bottom_nav_items"
    android:animateLayoutChanges="false"
    android:splitMotionEvents="false"/>

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Mithu
  • 665
  • 1
  • 8
  • 38
  • What did you try and what doesn't work? It's hard to understand what's wrong here. Perhaps you looking something like this but I'm not sure. https://developer.android.com/training/improving-layouts/reusing-layouts – Eugene Troyanskii Nov 26 '19 at 14:46
  • This is my current home layout xml. Need to Include the books.xml file to achieve the result like the image. is that possible? any suggestion – Mithu Nov 26 '19 at 14:51
  • But why you just don't add recyclerview to your main activity? Anyway I added link to the android documentation about include tag. – Eugene Troyanskii Nov 26 '19 at 14:53
  • when I am trying to add recyclerview to my main activity it is giving error 'E/RecyclerView: No adapter attached; skipping layout' problem but working perfect in my books.xml file. can not figure it out what's the problem.then thought if including layout can save me – Mithu Nov 26 '19 at 15:03
  • Include will not help you:D It would be better to fix your actual error with recycler https://stackoverflow.com/questions/29141729/recyclerview-no-adapter-attached-skipping-layout here is some tips – Eugene Troyanskii Nov 26 '19 at 15:21

0 Answers0