2015-07-25 16 views
13

Mam problemy z przezroczystością CardView i card_elewacją. Próbuje użyć CardView przejrzysty wynik to:Android CardView z dziwną ramką, gdy jest przezroczysty.

enter image description here

bez przezroczystości:

enter image description here

Co Próbuję uzyskać coś takiego:

enter image description here

Oto mój xml:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@mipmap/eifell" 
    android:padding="10dp" 
    tools:context=".MainActivity"> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="5dp" 
     android:background="@android:color/transparent"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <android.support.v7.widget.CardView 
       android:id="@+id/newsCardView" 
       android:layout_width="match_parent" 
       android:layout_height="175dp" 
       card_view:cardBackgroundColor="#602B608A" 
       card_view:cardElevation="5dp"> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="@android:color/transparent"> 
       </LinearLayout> 

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

     </LinearLayout> 
    </ScrollView> 

</RelativeLayout> 
+1

Czy kiedykolwiek obejście tego? Wygląda na to, że karty nie są zaprojektowane do obsługi przezroczystości tła: https://code.google.com/p/android/issues/detail?id=78061 –

+1

Witaj, Steve, nie, używam RelativeLayout z przezroczystym tłem bez cień (elewacja). Kiedy znalazłem coś, co opiszę gdzie. – cRobot

+0

@SteveBlackwell To jest ważna odpowiedź na to pytanie. Dzięki. –

Odpowiedz

5

Spróbuj kod:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:card_view="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/newsCardView" 
     android:layout_width="175dp" 
     android:layout_height="175dp" 
     card_view:cardBackgroundColor="#602B608A" 
     card_view:cardCornerRadius="0dp" 
     card_view:cardElevation="5dp"> 

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

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/imageView" 
     android:layout_gravity="left|top" 
     android:src="@drawable/fake_image" /> //REPLACE THIS WITH YOUR IMAGE 
</FrameLayout> 

enter image description here

Jeżeli nie pomogło, zapewnić cały kod xml układu

+0

Wszystko wygląda świetnie na moim urządzeniu, spróbuj zaktualizować bibliotekę cardView do com.android.support:cardview-v7:22.1.1 –

+0

Używam już tej wersji, jaką wersję Androida przetestowałeś? – cRobot

+0

Android 4.4.2 i Android 5.1.1 –

Powiązane problemy