2017-11-17 5 views
-1

Hier habe ich CircularNetworkImageView verwendet, weil ich Bild als runde Form möchte und ich habe die Eigenschaft imageview in Xml-Datei als android:scaleType="centerCrop", so muss es Ergebnis als Bild Mitte Bild haben, aber es nicht geben centercrop Bild .. Bilder werden selbst gab Zentrum Ernte gestreckt ....centercrop funktioniert nicht in CardView

enter image description here

Hier ist die xML-Datei

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.CardView 

    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="100dp" 
    android:layout_height="100dp" 
    xmlns:card_view="http://schemas.android.com/tools" 
    android:layout_margin="2dp" 
    card_view:cardPreventCornerOverlap="false" 
    android:orientation="vertical"> 

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

<com.example.taa.myfashion.adapters.CircularNetworkImageView 
    android:id="@+id/imageViewHero" 
    android:layout_gravity="center" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:adjustViewBounds="true" 
    android:scaleType="centerCrop" /> 

<TextView 
    android:id="@+id/textViewName" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="10dp" 
    android:textSize="12sp" /> 


</LinearLayout> 

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

Ihre Karte Blick ins Innere hinzufügen lineares Layout –

+0

@ Ravish Sharma, es hat nicht funktioniert – lesaint

Antwort

0

entfernen

<com.example.taa.myfashion.adapters.CircularNetworkImageView 
    android:id="@+id/imageViewHero" 
    android:layout_gravity="center" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:adjustViewBounds="true" 
    android:scaleType="centerCrop" /> 

und Code unten versuchen, statt CircularNetworkImageView

<android.support.v7.widget.CardView 
     android:id="@+id/profilePicCardView" 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:layout_centerVertical="true" 
     android:layout_margin="10dp" 
     android:elevation="12dp" 
     android:innerRadius="10dp" 
     android:shape="ring" 
     android:thicknessRatio="1.9" 
     app:cardCornerRadius="30dp"> 

     <ImageView 
      android:id="@+id/ivProfilePic" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:scaleType="centerCrop" /> 

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

Verwendung app:cardCornerRadius="30dp" Hälfte des height und width

zum Beispiel, wenn height & width60dp Verwendung ist 30dp

Verwandte Themen