CardView is not working perfectly in my android app, showing different in screen

cardview not showing android studio
cardview android
the following classes could not be found: - android support v7 widget cardview
material cardview dependency

I'm using android.support.v7.widget.CardView with match_parent and wrap_content. i want to make my layout responsive for all devices. all is working fine in android studio. but when i'm installing this app to an android device or emulator it's showing like the below image.

but i want to make this responsive with the width and height. please help me to solve this problem.

my fragment code is:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorBG"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        tools:context=".LiveTV"
        android:padding="10dp"
        android:orientation="vertical">

        <!-- TODO: Update blank fragment layout -->

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/news24"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/news24"
                        android:padding="10dp"/>

                </LinearLayout>
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/deshebideshe"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/deshebideshe"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>


        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/jamuna"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/jamuna"
                        android:padding="10dp"/>

                </LinearLayout>
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/satv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/satv"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/jagobanglatv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/jagobanglatv"
                        android:padding="10dp"/>

                </LinearLayout>
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/nrbtv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/nrbtv"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/rtvmusic"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/rtvmusic"
                        android:padding="10dp"/>

                </LinearLayout>
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/qtv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/qtv"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/panvisiontv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/panvisiontv"
                        android:padding="10dp"/>

                </LinearLayout>
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/millennium"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/millennium"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/btvworld"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/btvworld"
                        android:padding="10dp"/>

                </LinearLayout>
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/probashibangla"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/probashibangla"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>


    </LinearLayout>

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

thanks.


Android Programming for Beginners: Build in-depth, full-featured , CardView is not working perfectly in my android app, showing different CardView with match_parent and wrap_content. i want to make my You are the real hero. thanks for your help. is this layout will responsive with all display size? of imageView and then make the xml layout in 6 different usual size. Android RecyclerView and Android CardView got introduced in Android Lollipop with Material Design. For those who’re not aware of Material Design, its a comprehensive guide of UI Widgets introduced since Android 5.0 and it improves the visual appeal of the apps. Android RecyclerView is a more advanced, powerful and flexible version of the


add these lines in your linearLayout which is having two cardView

android:weightSum="2"

and add this line in both cardView

android:layout_weight="1"

and make cardView width 0dp like this

android:layout_width="0dp"

Android CardView 101: Everything you should know, CardView. and. ScrollView. Create a new project in the usual way. Name the project Leave the Target Android Devices section on the default settings and choose the On the Configure Activity screen, uncheck the option to Generate Layout File It is perfectly possible to build an app without using layout files and, as we  But be aware that adapting to different screen sizes doesn't necessarily make your app compatible with all Android form factors. You should take additional steps to support Android Wear, TV, Auto, and Chrome OS devices. For design guidelines for building UI for different screens, see the material guidelines for responsive UI. Create a flexible layout


i think your cardview doesnt look perfectly because of the size of images and i think if you use recyclerview and adapter by gridlayout manager will solve your proplem

recyclerView.setLayoutManager(new GridLayoutManager(this,numberofColumns));

in the top code if you put 2 instead of numberofColumns it will put two cardivew in every line and it will solve your problem,

if you dont want to use recyclerview you should give size to android:layout_width and android:layout_height of imageView and then make the xml layout in 6 different usual size

hdpi , xhdpi , xxhdpi , xxxhdpi , sw600dp and sw720dp

and it doenst look like a good solution

i hope it help you (:

Horizontal recyclerview in android, The only thing that separates a CardView from any other ViewGroups is its nature to app:cardBackgroundColor="@android:color/white"cardView. This causes a problem on phones with different pixel density and the required value has to  Clearing cache is the perhaps the most important and useful way to fix apps not working problem in Android. Just launch Settings app in Android and go to the “Application Manager”. Now tap the “All” tab in the center to list all the working apps in your device. Tap on the app which is not working.


Using Images as Background in CardView Pre-Lollipop device issues, While working on an Android App, there came a requirement to add Table But this is not the case when the user scrolls vertically. The 24. RecyclerView Android I will show how to create a horizontal list view of images bind with text which is RecyclerView The replacement for ListView, GridView and a couple of other  Android CardView Example with Gridlayout. (Large preview) 38- The app is complete, now build and run the app and you will see the same result as shown above. The source code for this tutorial is available on GitHub, I hope you find this tutorial helpful and if you have any question please post them in the comment below.


Android, This occurs due to the default rounded corners in the Card View. Here is how to <android.support.v7.widget.CardView 1 Card with image background in API 21 (perfectly fine). 2 Card with 35 Supporting different screen resolutions. 36 Glide 111 Building Backwards Compatible Apps 155 Displaying Google Ads. Using CoordinatorLayout in Android apps. 199. we are going to show three different out of the box ways that using CoordinatorLayout can simplify your code, by making views respond to changes


Android working with Card View and Recycler View, android documentation: Using Images as Background in CardView (Pre-Lollipop device issues) This occurs due to the default rounded corners in the Card View​. Here is how to avoid those margins in 1 Card with image background in API 21 (perfectly fine) Card with image background in API 21. 2 Card with image  There may be two causes for your apps not downloading. First, go back to the last page on this list and try clearing Google Play store's cache. If that doesn't work, try wiping Google Play's history.