Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add RecyclerView in dialog box

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.13k
    Comment on it

    In the below layout example, I have created a dialog box with RecyclerView. Here I have added first RecyclerView dependency to Grandle file. Now in next step I have Created a Main RelativeLayout. All layout added in Main RelativeLayout then created LinearLayout, TextView, ImageView, RecyclerView and button . You can see below program it will clearly describe you to add RecyclerView in dialog box.

    1. Step(1)Add the dependency to your Gradle file-
    2.  
    3. dependencies {
    4. ...
    5. compile "com.android.support:recyclerview-v7:23.0.1"
    6. }
    7.  
    8.  
    9. Step(2)activity_main.xml layout-
    10. <?xml version="1.0" encoding="utf-8"?>
    11.  
    12. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    13. android:layout_width="340dp"
    14. android:layout_height="wrap_content">
    15.  
    16. <RelativeLayout
    17. android:layout_width="match_parent"
    18. android:layout_height="match_parent"
    19. android:layout_marginLeft="18dp"
    20. android:layout_marginRight="10dp"
    21. android:layout_marginTop="15dp"
    22. android:layout_marginBottom="10dp"
    23. android:background="@mipmap/background">
    24. <LinearLayout
    25. android:layout_width="match_parent"
    26. android:layout_height="wrap_content"
    27. android:layout_weight="1"
    28. android:id="@+id/layout"
    29. android:orientation="vertical">
    30. <TextView
    31. android:layout_width="match_parent"
    32. android:layout_height="wrap_content"
    33. android:text="Select Category"
    34. android:gravity="center"
    35. android:textSize="18sp"
    36. android:textColor="@color/font_color"
    37. android:layout_marginTop="20dp"/>
    38. <ImageView
    39. android:layout_width="match_parent"
    40. android:layout_height="0.5dp"
    41. android:src="@color/font_color"
    42. android:layout_marginTop="10dp"/>
    43. <android.support.v7.widget.RecyclerView
    44. android:id="@+id/my_recycler_view"
    45. android:layout_width="match_parent"
    46. android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
    47.  
    48.  
    49.  
    50. </LinearLayout>
    51. <Button
    52.  
    53. android:id="@+id/signUpButton"
    54. android:layout_marginLeft="20dp"
    55. android:layout_marginRight="20dp"
    56. android:layout_width="match_parent"
    57. android:layout_height="wrap_content"
    58. android:layout_alignParentBottom="true"
    59. android:layout_marginBottom="40dp"
    60. android:background="@drawable/login_btn"
    61. android:text="Done"
    62. android:textSize="18sp"
    63. android:textColor="@color/font_color"/>
    64.  
    65. </RelativeLayout>
    66. <LinearLayout
    67. android:id="@+id/llTop"
    68. android:layout_width="wrap_content"
    69. android:layout_height="wrap_content"
    70. android:layout_alignParentLeft="true"
    71. android:layout_alignParentTop="true"
    72. android:orientation="vertical">
    73.  
    74. <ImageView
    75. android:id="@+id/btnCancel"
    76. android:layout_width="wrap_content"
    77. android:layout_height="wrap_content"
    78. android:background="@null"
    79. android:visibility="visible"
    80. android:src="@mipmap/ic_close_circle_outline_white_36dp"/>
    81.  
    82.  
    83.  
    84. </LinearLayout>
    85. </RelativeLayout>
    86.  
    87.  

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: