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.09k
    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.

    Step(1)Add the dependency to your Gradle file-
    
    dependencies {
        ...
        compile "com.android.support:recyclerview-v7:23.0.1"
    } 
    
    
    Step(2)activity_main.xml layout-
    <?xml version="1.0" encoding="utf-8"?>
    
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="340dp"
        android:layout_height="wrap_content">
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="18dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="15dp"
            android:layout_marginBottom="10dp"
            android:background="@mipmap/background">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:id="@+id/layout"
                android:orientation="vertical">
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Select Category"
                    android:gravity="center"
                    android:textSize="18sp"
                    android:textColor="@color/font_color"
                    android:layout_marginTop="20dp"/>
                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="0.5dp"
                    android:src="@color/font_color"
                    android:layout_marginTop="10dp"/>
                <android.support.v7.widget.RecyclerView
                    android:id="@+id/my_recycler_view"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
    
    
    
            </LinearLayout>
            <Button
    
                android:id="@+id/signUpButton"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_marginBottom="40dp"
                android:background="@drawable/login_btn"
                android:text="Done"
                android:textSize="18sp"
                android:textColor="@color/font_color"/>
    
        </RelativeLayout>
        <LinearLayout
            android:id="@+id/llTop"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:orientation="vertical">
    
            <ImageView
                android:id="@+id/btnCancel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@null"
                android:visibility="visible"
                android:src="@mipmap/ic_close_circle_outline_white_36dp"/>
    
    
    
        </LinearLayout>
    </RelativeLayout>
    
    

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: