Search code examples
androidcardview

make imageview accroding to cardview design


I have a CardView with rounded corners, I want to have an ImageView like cardview but it's not working.

I have implemented this code in another project it's working fine but it's not working in my project

please check my code i don't find any solution please help me.

my XML file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/rlimg"
    android:orientation="vertical"
    android:layout_width="@dimen/_150sdp"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView
        android:id="@+id/card_view"
        android:layout_width="@dimen/_150sdp"
        android:layout_height="wrap_content"
        app:cardElevation="@dimen/_3sdp"
        android:elevation="@dimen/_12sdp"
        android:layout_centerHorizontal="true"
        app:cardUseCompatPadding="true"
        app:cardPreventCornerOverlap="false"
        android:innerRadius="0dp"
        android:radius="0dp"
        app:cardCornerRadius="@dimen/_10sdp"
        android:shape="ring"
        android:thicknessRatio="1.9">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <ImageView
                android:id="@+id/imgperformarbg"
                android:layout_width="match_parent"
                android:layout_height="@dimen/_100sdp"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/publiek" />

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="@dimen/_100sdp"
                android:layout_gravity="bottom"
                android:scaleType="fitXY"
                android:src="@drawable/gradient"/>
        </RelativeLayout>

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/card_view"
        android:layout_marginLeft="@dimen/_4sdp"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Name"
            android:layout_marginBottom="@dimen/_5sdp"
            android:textColor="#E6000000"
            android:lineSpacingMultiplier=".9"
            android:minLines="1"
            android:maxLines="2"
            android:textSize="@dimen/_12sdp"
            android:id="@+id/txtperformarname"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Detail"
            android:layout_marginBottom="@dimen/_5sdp"
            android:textColor="#CC000000"
            android:textSize="@dimen/_10sdp"
            android:layout_below="@+id/txtperformarname"
            android:visibility="visible"
            android:id="@+id/txtdetails"/>
    </LinearLayout>
</RelativeLayout>

Gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.jenya.tix_tm"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 7
        versionName "1.0.6"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    //sdp
    implementation 'com.intuit.sdp:sdp-android:1.0.5'
    //BottomNavigationViewEx library
    implementation 'com.github.ittianyu:BottomNavigationViewEx:1.1.9'
    //glide
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    //cardview
    implementation 'com.android.support:cardview-v7:27.1.1'
    //volley
    implementation 'com.android.volley:volley:1.1.0'
    //recyclerview multi
    implementation 'com.github.takusemba:multisnaprecyclerview:1.3.3'
    //slider indecator
    implementation 'me.relex:circleindicator:1.2.2@aar'
    //font
    implementation 'com.elmargomez.typer:typerlib:1.0.0'
    //fab_loading
    implementation 'io.saeid:fab-loading:1.0.0'
    //loading_dots
    implementation 'com.github.bhargavms:DotLoader:1.1.1'
}

However, the material design guidelines states that card should have rounded corners and not square corners.

please help me I am new here

Any help would be highly appreciated.


Solution

  • The problem wasn't the layout or Glide. A few weeks ago I added this:

    android:hardwareAccelerated="false" android:largeHeap="true"

    to my Manifest because of memory management problems (my app would stop responding in Geneymotion). Turns out it created more problems than solving them.